Class EntityModelBuilder


  • public class EntityModelBuilder
    extends Object
    Builder for EntityModels
    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.
    • Constructor Detail

      • EntityModelBuilder

        public EntityModelBuilder​(Datastore datastore,
                                  Class<?> type)
        Create a builder
        Parameters:
        datastore - the datastore to use
        type - the entity type
      • EntityModelBuilder

        public EntityModelBuilder​(Datastore datastore,
                                  A annotation,
                                  Class<T> clazz)
        Type Parameters:
        T - the class type
        A - the annotation type
        Parameters:
        datastore - the datastore
        annotation - the annotation
        clazz - the type
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Method Detail

      • addProperty

        public PropertyModelBuilder addProperty()
        Adds a property to the model
        Returns:
        the new PropertyModelBuilder
      • classHierarchy

        public Set<Class<?>> classHierarchy()
        Returns:
        the parent class hierarchy
        Since:
        2.2
      • getAnnotation

        @Nullable
        public <A extends Annotation> A getAnnotation​(Class<A> type)
        Type Parameters:
        A - the annotation type
        Parameters:
        type - the annotation class
        Returns:
        the annotation or null if it doesn't exist
      • annotations

        public Set<Annotation> annotations()
        Returns:
        the annotation on this model
      • build

        public EntityModel build()
        Creates a new ClassModel instance based on the mapping data provided.
        Returns:
        the new instance
      • discriminator

        public EntityModelBuilder discriminator​(String discriminator)
        Sets the discriminator
        Parameters:
        discriminator - the discriminator
        Returns:
        this
      • discriminator

        public String discriminator()
        Returns:
        the discriminator
      • discriminatorKey

        public EntityModelBuilder discriminatorKey​(String key)
        Sets the mapped key name to use when storing the discriminator value
        Parameters:
        key - the key to use
        Returns:
        this
      • discriminatorKey

        public String discriminatorKey()
        Returns:
        the discriminator key
      • enableDiscriminator

        public EntityModelBuilder enableDiscriminator​(boolean enabled)
        Enables or disables the use of a discriminator when serializing
        Parameters:
        enabled - true to enable the use of a discriminator
        Returns:
        this
      • idPropertyName

        @Nullable
        public String idPropertyName()
        Returns:
        the name of the id property
      • idPropertyName

        public EntityModelBuilder idPropertyName​(String name)
        Sets the name of the id property
        Parameters:
        name - the name
        Returns:
        this
      • superclass

        @Nullable
        public EntityModel superclass()
        Returns:
        the super class of this type or null
      • getType

        public Class<?> getType()
        The type of this model
        Returns:
        the type
      • hasAnnotation

        public boolean hasAnnotation​(Class<? extends Annotation> type)
        Parameters:
        type - the annotation class
        Returns:
        the annotation if it exists
      • versionPropertyName

        @Nullable
        public String versionPropertyName()
        Returns:
        the name of the version property
      • versionPropertyName

        public EntityModelBuilder versionPropertyName​(String name)
        Sets the name of the version property
        Parameters:
        name - the name
        Returns:
        this
      • interfaces

        public List<EntityModel> interfaces()
        Returns:
        the interfaces implemented by this model or its super types
      • isDiscriminatorEnabled

        public boolean isDiscriminatorEnabled()
        Returns:
        true if the discriminator is enabled
      • getCollectionName

        protected String getCollectionName()
      • getDatastore

        protected Datastore getDatastore()