Package dev.morphia.mapping
Class MapperOptions.Builder
- java.lang.Object
-
- dev.morphia.mapping.MapperOptions.Builder
-
- Enclosing class:
- MapperOptions
public static final class MapperOptions.Builder extends Object
A builder class for setting mapping options
-
-
Constructor Summary
Constructors Constructor Description Builder(MapperOptions original)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MapperOptions.Builder
addConvention(MorphiaConvention convention)
Adds a custom convention to the list to be applied to all new MorphiaModels.MapperOptions
build()
MapperOptions.Builder
cacheClassLookups(boolean cacheClassLookups)
MapperOptions.Builder
classLoader(ClassLoader classLoader)
MapperOptions.Builder
collectionNaming(NamingStrategy strategy)
Sets the naming strategy to use for collection namesMapperOptions.Builder
dateForm(DateStorage dateStorage)
Deprecated.usedateStorage(DateStorage)
instead.MapperOptions.Builder
dateStorage(DateStorage dateStorage)
The default value for this isDateStorage.UTC
.MapperOptions.Builder
disableEmbeddedIndexes(boolean disableEmbeddedIndexes)
Deprecated, for removal: This API element is subject to removal in a future version.unusedMapperOptions.Builder
discriminator(DiscriminatorFunction function)
Sets the discriminator function to useMapperOptions.Builder
discriminatorKey(String key)
Defines the discriminator key nameMapperOptions.Builder
enablePolymorphicQueries(boolean enablePolymorphicQueries)
MapperOptions.Builder
fieldNaming(NamingStrategy strategy)
Deprecated, for removal: This API element is subject to removal in a future version.usepropertyNaming(NamingStrategy)
insteadMapperOptions.Builder
ignoreFinals(boolean ignoreFinals)
MapperOptions.Builder
mapSubPackages(boolean mapSubPackages)
MapperOptions.Builder
propertyDiscovery(MapperOptions.PropertyDiscovery discovery)
Determines how properties are discovered on mapped entitiesMapperOptions.Builder
propertyNaming(NamingStrategy strategy)
Sets the naming strategy to use for propertys unless expliclity set via @PropertyMapperOptions.Builder
queryFactory(QueryFactory queryFactory)
MapperOptions.Builder
storeEmpties(boolean storeEmpties)
MapperOptions.Builder
storeNulls(boolean storeNulls)
MapperOptions.Builder
useLowerCaseCollectionNames(boolean useLowerCaseCollectionNames)
Deprecated, for removal: This API element is subject to removal in a future version.usecollectionNaming(NamingStrategy)
insteadMapperOptions.Builder
uuidRepresentation(org.bson.UuidRepresentation uuidRepresentation)
Configures the UUID representation to use
-
-
-
Constructor Detail
-
Builder
public Builder(MapperOptions original)
-
-
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
-
classLoader
public MapperOptions.Builder classLoader(ClassLoader classLoader)
- Parameters:
classLoader
- the ClassLoader to use- 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
-
dateForm
@Deprecated public MapperOptions.Builder dateForm(DateStorage dateStorage)
Deprecated.usedateStorage(DateStorage)
instead.- Parameters:
dateStorage
- the storage format to use for dates- Returns:
- this
-
dateStorage
public MapperOptions.Builder dateStorage(DateStorage dateStorage)
The default value for this isDateStorage.UTC
. To use theDateStorage.SYSTEM_DEFAULT
, either set this value explicitly here or use theMapperOptions.legacy()
Builder.- Parameters:
dateStorage
- the storage format to use for dates- Returns:
- this
- Since:
- 2.0
-
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
-
discriminator
public MapperOptions.Builder discriminator(DiscriminatorFunction function)
Sets the discriminator function to use- Parameters:
function
- the function to use- 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
-
fieldNaming
@Deprecated(forRemoval=true) public MapperOptions.Builder fieldNaming(NamingStrategy strategy)
Deprecated, for removal: This API element is subject to removal in a future version.usepropertyNaming(NamingStrategy)
insteadSets the naming strategy to use for fields unless expliclity set via @Property- Parameters:
strategy
- the strategy to use- Returns:
- this
- See Also:
Property
-
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
-
propertyDiscovery
public MapperOptions.Builder propertyDiscovery(MapperOptions.PropertyDiscovery discovery)
Determines how properties are discovered on mapped entities- Parameters:
discovery
-- Returns:
- this
- Since:
- 2.2
-
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.usecollectionNaming(NamingStrategy)
instead- 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
-
-