Class ClassModelBuilder<T>

  • Type Parameters:
    T - The type of the class the ClassModel represents


    public class ClassModelBuilder<T>
    extends Object
    A builder for programmatically creating ClassModels.
    Since:
    3.5
    See Also:
    ClassModel
    • Method Detail

      • idGenerator

        public ClassModelBuilder<T> idGenerator​(IdGenerator<?> idGenerator)
        Sets the IdGenerator for the ClassModel
        Parameters:
        idGenerator - the IdGenerator
        Returns:
        this
        Since:
        3.10
      • getIdGenerator

        public IdGenerator<?> getIdGenerator​()
        Returns:
        the IdGenerator for the ClassModel, or null if not set
        Since:
        3.10
      • instanceCreatorFactory

        public ClassModelBuilder<T> instanceCreatorFactory​(InstanceCreatorFactory<T> instanceCreatorFactory)
        Sets the InstanceCreatorFactory for the ClassModel
        Parameters:
        instanceCreatorFactory - the InstanceCreatorFactory
        Returns:
        this
      • getInstanceCreatorFactory

        public InstanceCreatorFactory<T> getInstanceCreatorFactory​()
        Returns:
        the InstanceCreatorFactory for the ClassModel
      • type

        public ClassModelBuilder<T> type​(Class<T> type)
        Sets the type of the model
        Parameters:
        type - the type of the class
        Returns:
        the builder to configure the class being modeled
      • getType

        public Class<T> getType​()
        Returns:
        the type if set or null
      • conventions

        public ClassModelBuilder<T> conventions​(List<Convention> conventions)
        Sets the conventions to apply to the model
        Parameters:
        conventions - a list of conventions
        Returns:
        this
      • getConventions

        public List<Convention> getConventions​()
        Returns:
        the conventions o apply to the model
      • annotations

        public ClassModelBuilder<T> annotations​(List<Annotation> annotations)
        Sets the annotations for the model
        Parameters:
        annotations - a list of annotations
        Returns:
        this
      • getAnnotations

        public List<Annotation> getAnnotations​()
        Returns:
        the annotations on the modeled type if set or null
      • discriminator

        public ClassModelBuilder<T> discriminator​(String discriminator)
        Sets the discriminator to be used when storing instances of the modeled type
        Parameters:
        discriminator - the discriminator value
        Returns:
        this
      • getDiscriminator

        public String getDiscriminator​()
        Returns:
        the discriminator to be used when storing instances of the modeled type or null if not set
      • discriminatorKey

        public ClassModelBuilder<T> discriminatorKey​(String discriminatorKey)
        Sets the discriminator key to be used when storing instances of the modeled type
        Parameters:
        discriminatorKey - the discriminator key value
        Returns:
        this
      • getDiscriminatorKey

        public String getDiscriminatorKey​()
        Returns:
        the discriminator key to be used when storing instances of the modeled type or null if not set
      • enableDiscriminator

        public ClassModelBuilder<T> enableDiscriminator​(boolean discriminatorEnabled)
        Enables or disables the use of a discriminator when serializing
        Parameters:
        discriminatorEnabled - true to enable the use of a discriminator
        Returns:
        this
      • useDiscriminator

        public Boolean useDiscriminator​()
        Returns:
        true if a discriminator should be used when serializing, otherwise false
      • idPropertyName

        public ClassModelBuilder<T> idPropertyName​(String idPropertyName)
        Designates a property as the _id property for this type. If another property is currently marked as the _id property, that setting is cleared in favor of the named property.
        Parameters:
        idPropertyName - the property name to use for the _id property, a null value removes the set idPropertyName.
        Returns:
        this
      • getIdPropertyName

        public String getIdPropertyName​()
        Returns:
        the designated _id property name for this type or null if not set
      • removeProperty

        public boolean removeProperty​(String propertyName)
        Remove a property from the builder
        Parameters:
        propertyName - the actual property name in the POJO and not the documentPropertyName.
        Returns:
        returns true if the property matched and was removed
      • getProperty

        public PropertyModelBuilder<?> getProperty​(String propertyName)
        Gets a property by the property name.
        Parameters:
        propertyName - the name of the property to find.
        Returns:
        the property or null if the property is not found
      • getPropertyModelBuilders

        public List<PropertyModelBuilder<?>> getPropertyModelBuilders​()
        Returns:
        the properties on the modeled type
      • build

        public ClassModel<T> build​()
        Creates a new ClassModel instance based on the mapping data provided.
        Returns:
        the new instance