Skip to content

Make supporting @TypeAlias the default behavior #1119

Closed
@mikereiche

Description

@mikereiche

Make supporting @\TypeAlias the default behavior. This currently requires a CustomMappingCouchbaseConverter which uses a TypeBasedTypeMapper which uses a TypeAwareInformationMapper - see src/test/java/org/springframework/data/couchbase/domain/Config

By packaging and using that TypeAwareInformationMapper (that considers @\TypeAlias) instead of Simple

	public DefaultCouchbaseTypeMapper(final String typeKey) {
		//super(new CouchbaseDocumentTypeAliasAccessor(typeKey));
		super(new CouchbaseDocumentTypeAliasAccessor(typeKey), (MappingContext)null, Collections.singletonList(new TypeAwareTypeInformationMapper()));
		this.typeKey = typeKey;
	}

override this:

public Alias createAliasFor(TypeInformation<?> type) {
    return Alias.of(type.getType().getName());
 }

with this:

@Override
public Alias createAliasFor(TypeInformation<?> type) {
	TypeAlias[] typeAlias = type.getType().getAnnotationsByType(TypeAlias.class);
		if (typeAlias.length == 1) {
		return Alias.of(typeAlias[0].value());
	}
	return super.createAliasFor(type);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions