Package org.bson.codecs.pojo
Class PojoCodecProvider.Builder
- java.lang.Object
-
- org.bson.codecs.pojo.PojoCodecProvider.Builder
-
- Enclosing class:
- PojoCodecProvider
public static final class PojoCodecProvider.Builder extends Object
A Builder for the PojoCodecProvider
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PojoCodecProvider.Builderautomatic(boolean automatic)Sets whether the provider should automatically try to wrap aClassModelfor any class that is requested.PojoCodecProviderbuild()Creates the PojoCodecProvider with the classes or packages that configured and registered.PojoCodecProvider.Builderconventions(List<Convention> conventions)Sets the conventions to use when creatingClassModelsfrom classes or packages.PojoCodecProvider.Builderregister(Class<?>... classes)Registers a classes with the builder for inclusion in the Provider.PojoCodecProvider.Builderregister(String... packageNames)Registers the packages of the given classes with the builder for inclusion in the Provider.PojoCodecProvider.Builderregister(ClassModel<?>... classModels)Registers classModels for inclusion in the Provider.PojoCodecProvider.Builderregister(PropertyCodecProvider... providers)Registers codec providers that receive the type parameters of properties for instances encoded and decoded by aPojoCodechandled by this provider.
-
-
-
Method Detail
-
build
public PojoCodecProvider build()
Creates the PojoCodecProvider with the classes or packages that configured and registered.- Returns:
- the Provider
- See Also:
register(Class...)
-
automatic
public PojoCodecProvider.Builder automatic(boolean automatic)
Sets whether the provider should automatically try to wrap aClassModelfor any class that is requested.Note: As Java Beans are convention based, when using automatic settings the provider should be the last provider in the registry.
- Parameters:
automatic- whether to automatically wrapClassModelsor not.- Returns:
- this
-
conventions
public PojoCodecProvider.Builder conventions(List<Convention> conventions)
Sets the conventions to use when creatingClassModelsfrom classes or packages.- Parameters:
conventions- a list of conventions- Returns:
- this
-
register
public PojoCodecProvider.Builder register(Class<?>... classes)
Registers a classes with the builder for inclusion in the Provider.Note: Uses reflection for the property mapping. If no conventions are configured on the builder the
Conventions.DEFAULT_CONVENTIONSwill be used.- Parameters:
classes- the classes to register- Returns:
- this
-
register
public PojoCodecProvider.Builder register(ClassModel<?>... classModels)
Registers classModels for inclusion in the Provider.- Parameters:
classModels- the classModels to register- Returns:
- this
-
register
public PojoCodecProvider.Builder register(String... packageNames)
Registers the packages of the given classes with the builder for inclusion in the Provider. This will allow classes in the given packages to mapped for use with PojoCodecProvider.Note: Uses reflection for the field mapping. If no conventions are configured on the builder the
Conventions.DEFAULT_CONVENTIONSwill be used.- Parameters:
packageNames- the package names to register- Returns:
- this
-
register
public PojoCodecProvider.Builder register(PropertyCodecProvider... providers)
Registers codec providers that receive the type parameters of properties for instances encoded and decoded by aPojoCodechandled by this provider.Note that you should prefer working with the
CodecRegistry/CodecProviderhierarchy. Providers should only be registered here if a codec needs to be created for custom container types like optionals and collections. Support for typesMapandCollectionare built-in so explicitly handling them is not necessary.- Parameters:
providers- property codec providers to register- Returns:
- this
- Since:
- 3.6
-
-