Search in sources :

Example 1 with Version

use of dev.morphia.annotations.Version in project morphia by mongodb.

the class PropertyModelBuilder method discoverMappedName.

public PropertyModelBuilder discoverMappedName() {
    MapperOptions options = mapper.getOptions();
    Property property = getAnnotation(Property.class);
    Reference reference = getAnnotation(Reference.class);
    Version version = getAnnotation(Version.class);
    if (hasAnnotation(Id.class)) {
        mappedName("_id");
    } else if (property != null && !property.value().equals(Mapper.IGNORED_FIELDNAME)) {
        mappedName(property.value());
    } else if (reference != null && !reference.value().equals(Mapper.IGNORED_FIELDNAME)) {
        mappedName(reference.value());
    } else if (version != null && !version.value().equals(Mapper.IGNORED_FIELDNAME)) {
        mappedName(version.value());
    } else {
        mappedName(options.getFieldNaming().apply(name()));
    }
    return this;
}
Also used : MapperOptions(dev.morphia.mapping.MapperOptions) Version(dev.morphia.annotations.Version) Reference(dev.morphia.annotations.Reference) Property(dev.morphia.annotations.Property)

Aggregations

Property (dev.morphia.annotations.Property)1 Reference (dev.morphia.annotations.Reference)1 Version (dev.morphia.annotations.Version)1 MapperOptions (dev.morphia.mapping.MapperOptions)1