class SchemaNameAsAttribute implements SchemaAccessWriter {

    @Override
    public Map<String, String> getAttributes(final RecordSchema schema) {
        final Map<String,String> attributes = new HashMap<>(3);

        final SchemaIdentifier identifier = schema.getIdentifier();

        final Optional<String> nameOption = identifier.getName();
        if (nameOption.isPresent()) {
            attributes.put(SCHEMA_NAME_ATTRIBUTE, nameOption.get());
        }

        final OptionalInt versionOption = identifier.getVersion();
        if (versionOption.isPresent()) {
            attributes.put(SCHEMA_VERSION_ATTRIBUTE, String.valueOf(versionOption.getAsInt()));
        }

        final Optional<String> branchOption = identifier.getBranch();
        if (branchOption.isPresent()) {
            attributes.put(SCHEMA_BRANCH_ATTRIBUTE, branchOption.get());
        }

        return attributes;
    }

}