Class PropertyModelBuilder


  • public final class PropertyModelBuilder
    extends Object
    A builder for programmatically creating FieldModels.
    Since:
    2.0
    Developer note.
    This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Method Detail

      • annotation

        public PropertyModelBuilder annotation​(Annotation annotation)
        Adds an annotation
        Parameters:
        annotation - the annotation
        Returns:
        this
        Since:
        2.3
      • accessor

        public org.bson.codecs.pojo.PropertyAccessor<? super Object> accessor()
        Returns:
        the accessor for this model
      • accessor

        public PropertyModelBuilder accessor​(org.bson.codecs.pojo.PropertyAccessor<? super Object> accessor)
        Sets the PropertyAccessor
        Parameters:
        accessor - the accessor
        Returns:
        this
      • alternateName

        public void alternateName​(String name)
        Adds an alternate name
        Parameters:
        name - the new name
      • alternateNames

        public List<String> alternateNames()
        Returns:
        the list of alternate names this model can be known by
        See Also:
        AlsoLoad
      • annotations

        public List<Annotation> annotations()
        Returns the read annotations, to be applied when serializing to BSON
        Returns:
        the read annotations
      • discriminatorEnabled

        public PropertyModelBuilder discriminatorEnabled​(Boolean discriminatorEnabled)
        Enables/disables the use of the discriminator during mapping
        Parameters:
        discriminatorEnabled - true if the discriminator should be used
        Returns:
        this
      • discriminatorEnabled

        public Boolean discriminatorEnabled()
        Returns:
        true if the discriminator is to be used
      • getAnnotation

        @Nullable
        public <A extends Annotation> A getAnnotation​(Class<A> type)
        Gets the annotation of this type.
        Type Parameters:
        A - the annotation type
        Parameters:
        type - the annotation class
        Returns:
        the annotation instance or null if this annotation is on the field
      • hasAnnotation

        public boolean hasAnnotation​(Class<? extends Annotation> type)
        Checks this field for an annotation of the given type
        Parameters:
        type - the annotation class
        Returns:
        true if the annotation is used on this field
      • mappedName

        public PropertyModelBuilder mappedName​(String mappedName)
        Sets the field's mapped name
        Parameters:
        mappedName - the name
        Returns:
        this
      • mappedName

        public String mappedName()
        Returns:
        the field's mapped name
      • modifiers

        public int modifiers()
      • name

        public String name()
        Returns:
        the field name
      • owner

        public PropertyModelBuilder owner​(EntityModel entityModel)
        Sets the entity model owner
        Parameters:
        entityModel - the entity model
        Returns:
        this
        Since:
        2.1
      • owner

        public EntityModel owner()
        Returns:
        the entity model owner
        Since:
        2.1
      • serialization

        public PropertyModelBuilder serialization​(MorphiaPropertySerialization propertySerialization)
        Sets the PropertySerialization checker
        Parameters:
        propertySerialization - checks if a property should be serialized
        Returns:
        this
      • typeData

        public TypeData<?> typeData()
        Returns:
        the type data
      • typeData

        public PropertyModelBuilder typeData​(TypeData<?> typeData)
        Sets the type data
        Parameters:
        typeData - the type data
        Returns:
        this