public final class Configuration
extends java.lang.Object
ObjectBuilder. Create an instance of Configuration with default settings by calling
defaultConfiguration() and apply overrides.| Modifier and Type | Method and Description |
|---|---|
static Configuration |
defaultConfiguration()
Create a new instance of
Configuration by default settings pre-configured. |
Configuration |
withBuildStrategy(Type<?> type,
BuildStrategy buildStrategy)
This will override the default build strategy set for a specific type.
|
Configuration |
withCacheAll()
Enable caching of all objects.
|
Configuration |
withCaching(java.util.function.Predicate<Type<?>> predicate)
Enable caching only on all types matching this predicate.
|
Configuration |
withCachingAllExcluding(java.util.Collection<Type<?>> types)
Enable caching on all types excluding these.
|
Configuration |
withCachingAllExcluding(Type<?>... types)
Enable caching on all types excluding these.
|
Configuration |
withCachingOnly(java.util.Collection<Type<?>> types)
Enable caching only on the given types.
|
Configuration |
withCachingOnly(Type<?>... types)
Enable caching only on the given types.
|
Configuration |
withDefaultBuildStrategy(BuildStrategy defaultBuildStrategy)
The default build strategy described how objects should be instantiated.
|
Configuration |
withFailOnError(boolean failOnError)
If set to true, the builder will throw an exception on the first occurrence of an error level issue.
|
Configuration |
withFailOnWarning(boolean failOnWarning)
If set to true, the builder will throw an exception on the first occurrence of an warning level issue.
|
Configuration |
withMaxDepth(int maxDepth)
Define the max depth to which ObjectBuilder should build to.
|
<T extends AnyValueTypeProvider> |
withNullProvider(T nullProvider)
Configure the provider that will be used to generate null values.
|
Configuration |
withPathFilter(PathFilter pathFilter)
Filter out paths that should not be built.
|
Configuration |
withPrefabValue(Type<?> type,
java.lang.Object value)
Define a prefabricated for a given type.
|
Configuration |
withProvider(Provider provider)
Add a custom provider.
|
public Configuration withMaxDepth(int maxDepth)
maxDepth - max depthpublic Configuration withPathFilter(PathFilter pathFilter)
pathFilter - path filterpublic <T extends AnyValueTypeProvider> Configuration withNullProvider(T nullProvider)
NullProvider, which returns null for all class types
and null equivalent values for primitives, such as 0 for int.T - provider typenullProvider - null providedpublic Configuration withFailOnError(boolean failOnError)
failOnError - fail on errorpublic Configuration withFailOnWarning(boolean failOnWarning)
failOnWarning - fail on warningpublic Configuration withProvider(Provider provider)
provider - providerpublic Configuration withCacheAll()
ObjectBuilder and not shared across multiple instances. Note, calling one of the
other caching methods such as withCachingAllExcluding(Type...), withCachingOnly(Type...), or
withCaching(Predicate), will unset any settings defined by this method call.public Configuration withCachingOnly(Type<?>... types)
ObjectBuilder and not shared across multiple instances. Note, calling one of the
other caching methods such as withCachingAllExcluding(Type...), withCacheAll(), or withCaching(Predicate), will
unset any settings defined by this method call.types - types to cachepublic Configuration withCachingOnly(java.util.Collection<Type<?>> types)
ObjectBuilder and not shared across multiple instances. Note, calling one of the
other caching methods such as withCachingAllExcluding(Type...), withCacheAll(), or withCaching(Predicate), will
unset any settings defined by this method call.types - types to cachepublic Configuration withCachingAllExcluding(Type<?>... types)
Provider will
be called each time an object of this type is required. Note, calling one of the other caching methods such as
withCachingOnly(Type...), withCacheAll(), or withCaching(Predicate), will unset any settings defined by
this method call.types - types not to cachepublic Configuration withCachingAllExcluding(java.util.Collection<Type<?>> types)
Provider will
be called each time an object of this type is required. Note, calling one of the other caching methods such as
withCachingOnly(Type...), withCacheAll(), or withCaching(Predicate), will unset any settings defined by
this method call.types - types not to cachepublic Configuration withCaching(java.util.function.Predicate<Type<?>> predicate)
ObjectBuilder and not shared across multiple instances. Note, calling
one of the other caching methods such as withCachingAllExcluding(Type...), withCacheAll(), or
withCachingOnly(Collection), will unset any settings defined by this method call.predicate - predicate to decide if a type should be cachedpublic Configuration withPrefabValue(Type<?> type, java.lang.Object value)
Provider.type - typevalue - valuepublic Configuration withDefaultBuildStrategy(BuildStrategy defaultBuildStrategy)
Provider. The default build strategy will be used for all types unless a specific build strategy has been
configured at type level by calling withBuildStrategy(Type, BuildStrategy). If unspecified, the defaultBuildStrategy of
BuildStrategy.AUTO will be used.defaultBuildStrategy - default build strategypublic Configuration withBuildStrategy(Type<?> type, BuildStrategy buildStrategy)
type - typebuildStrategy - build strategypublic static Configuration defaultConfiguration()
Configuration by default settings pre-configured. You can then override the defaults as required.