use of org.springframework.data.mapping.Alias in project spring-data-mongodb by spring-projects.
the class DefaultMongoTypeMapper method writeTypeRestrictions.
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.convert.MongoTypeMapper#writeTypeRestrictions(java.util.Set)
*/
@Override
public void writeTypeRestrictions(Document result, @Nullable Set<Class<?>> restrictedTypes) {
if (ObjectUtils.isEmpty(restrictedTypes)) {
return;
}
BasicDBList restrictedMappedTypes = new BasicDBList();
for (Class<?> restrictedType : restrictedTypes) {
Alias typeAlias = getAliasFor(ClassTypeInformation.from(restrictedType));
if (!ObjectUtils.nullSafeEquals(Alias.NONE, typeAlias) && typeAlias.isPresent()) {
restrictedMappedTypes.add(typeAlias.getValue());
}
}
accessor.writeTypeTo(result, new Document("$in", restrictedMappedTypes));
}
Aggregations