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
      • 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
      • 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

        public MapperOptions.Builder uuidRepresentation​(org.bson.UuidRepresentation uuidRepresentation)
        Configures the UUID representation to use
        Parameters:
        uuidRepresentation - the representation
        Returns:
        this