Class ClassModelBuilder<T>

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

    public class ClassModelBuilder<T>
    extends java.lang.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​(java.lang.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 java.lang.Class<T> getType()
        Returns:
        the type if set or null
      • conventions

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

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

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

        public java.util.List<java.lang.annotation.Annotation> getAnnotations()
        Returns:
        the annotations on the modeled type if set or null
      • discriminator

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

        public java.lang.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​(java.lang.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 java.lang.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 java.lang.Boolean useDiscriminator()
        Returns:
        true if a discriminator should be used when serializing, otherwise false
      • idPropertyName

        public ClassModelBuilder<T> idPropertyName​(java.lang.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 java.lang.String getIdPropertyName()
        Returns:
        the designated _id property name for this type or null if not set
      • removeProperty

        public boolean removeProperty​(java.lang.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​(java.lang.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 java.util.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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object