Class MapperOptions.Builder

  • Enclosing class:
    MapperOptions

    public static final class MapperOptions.Builder
    extends Object
    A builder class for setting mapping options
    • Method Detail

      • addConvention

        public MapperOptions.Builder addConvention​(MorphiaConvention convention)
        Adds a custom convention to the list to be applied to all new MorphiaModels.
        Parameters:
        convention - the new convention
        Returns:
        this
        Since:
        2.0
      • autoImportModels

        public MapperOptions.Builder autoImportModels​(boolean autoImportModels)
        This feature automatically discovers and uses EntityModelImporter instances to allow for external definition of class models. This feature defaults to true.
        Parameters:
        autoImportModels - Set to true to auto import definitions via EntityModelImporter. Defaults to true.
        Returns:
        this
      • build

        public MapperOptions build()
        Returns:
        the new options instance
      • cacheClassLookups

        public MapperOptions.Builder cacheClassLookups​(boolean cacheClassLookups)
        Parameters:
        cacheClassLookups - if true class lookups are cached
        Returns:
        this
      • codecProvider

        @MorphiaExperimental
        public MapperOptions.Builder codecProvider​(CodecProvider codecProvider)
        Sets a provider for user defined codecs to used by Morphia
        Parameters:
        codecProvider - the provider to user
        Returns:
        this
        Since:
        2.3
        Developer note.
        This is an experimental item. Its function and presence are subject to change. Feedback on features and usability extremely welcome.
      • collectionNaming

        public MapperOptions.Builder collectionNaming​(NamingStrategy strategy)
        Sets the naming strategy to use for collection names
        Parameters:
        strategy - the strategy to use
        Returns:
        this
      • disableEmbeddedIndexes

        @Deprecated(forRemoval=true)
        public MapperOptions.Builder disableEmbeddedIndexes​(boolean disableEmbeddedIndexes)
        Deprecated, for removal: This API element is subject to removal in a future version.
        unused
        Parameters:
        disableEmbeddedIndexes - if true scanning @Embedded properties for indexing is disabled
        Returns:
        this
      • discriminatorKey

        public MapperOptions.Builder discriminatorKey​(String key)
        Defines the discriminator key name
        Parameters:
        key - the key to use, e.g., "_t". the default/legacy value is "className"
        Returns:
        this
      • enablePolymorphicQueries

        public MapperOptions.Builder enablePolymorphicQueries​(boolean enablePolymorphicQueries)
        Parameters:
        enablePolymorphicQueries - if true queries are updated, in some cases, to check for subtypes' discriminator values so that subtype might be returned by a query.
        Returns:
        this
      • ignoreFinals

        public MapperOptions.Builder ignoreFinals​(boolean ignoreFinals)
        Parameters:
        ignoreFinals - if true final fields are ignored
        Returns:
        this
      • mapSubPackages

        public MapperOptions.Builder mapSubPackages​(boolean mapSubPackages)
        Parameters:
        mapSubPackages - if true subpackages are mapped when given a particular package
        Returns:
        this
      • propertyNaming

        public MapperOptions.Builder propertyNaming​(NamingStrategy strategy)
        Sets the naming strategy to use for propertys unless expliclity set via @Property
        Parameters:
        strategy - the strategy to use
        Returns:
        this
        Since:
        2.2
        See Also:
        Property
      • queryFactory

        public MapperOptions.Builder queryFactory​(QueryFactory queryFactory)
        Parameters:
        queryFactory - the query factory to use when creating queries
        Returns:
        this
      • storeEmpties

        public MapperOptions.Builder storeEmpties​(boolean storeEmpties)
        Parameters:
        storeEmpties - if true empty maps and collection types are stored in the database
        Returns:
        this
      • storeNulls

        public MapperOptions.Builder storeNulls​(boolean storeNulls)
        Parameters:
        storeNulls - if true null values are stored in the database
        Returns:
        this
      • useLowerCaseCollectionNames

        @Deprecated(since="2.0",
                    forRemoval=true)
        public MapperOptions.Builder useLowerCaseCollectionNames​(boolean useLowerCaseCollectionNames)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Parameters:
        useLowerCaseCollectionNames - if true, generated collections names are lower cased
        Returns:
        this
      • uuidRepresentation

        @Deprecated(forRemoval=true,
                    since="2.3")
        public MapperOptions.Builder uuidRepresentation​(UuidRepresentation uuidRepresentation)
        Deprecated, for removal: This API element is subject to removal in a future version.
        This should be configured in the MongoClient given to Morphia
        Configures the UUID representation to use
        Parameters:
        uuidRepresentation - the representation
        Returns:
        this