Class ObfuscationModule.Builder
java.lang.Object
com.github.robtimus.obfuscation.jackson.databind.ObfuscationModule.Builder
- Enclosing class:
- ObfuscationModule
A builder for
ObfuscationModules.- Author:
- Rob Spoor
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a newObfuscationModulewith the current settings of this builder.requireObfuscatorAnnotation(boolean requireObfuscatorAnnotation) Sets whether or not to require an annotation to provide an obfuscator forList,Set,CollectionandMapfields.withDefaultCharacterRepresentation(Class<?> type, CharacterRepresentationProvider defaultProvider) Sets the default character representation provider to use for a specific type, in case no character representation provider could be found from annotations.withDefaultObfuscator(Obfuscator defaultObfuscator) Sets the default obfuscator to use, in case no obfuscator could be found from annotations.withDefaultObfuscator(Class<?> type, Obfuscator defaultObfuscator) Sets the default obfuscator to use for a specific type, in case no obfuscator could be found from annotations.withObjectFactory(ObjectFactory objectFactory) Sets the object factory to use.
-
Method Details
-
withObjectFactory
Sets the object factory to use. This method can be used to override the default object factory, for instance to use an object factory that uses a Spring bean factory or CDI lookup. The default usesClassUtil.createInstance(Class, boolean), withMapperConfig.canOverrideAccessModifiers()providing the boolean flag.- Parameters:
objectFactory- The object factory to use, ornullto use a default object factory.- Returns:
- This object.
- Since:
- 1.2
- See Also:
-
withDefaultObfuscator
Sets the default obfuscator to use, in case no obfuscator could be found from annotations. The default isObfuscator.fixedLength(3).- Parameters:
defaultObfuscator- The default obfuscator to use.- Returns:
- This object.
- Throws:
NullPointerException- If the given obfuscator isnull.
-
withDefaultObfuscator
Sets the default obfuscator to use for a specific type, in case no obfuscator could be found from annotations. This type should be the generic type of anyObfuscated,List,Set,CollectionorMap. It doesn't need to be the exact type; it can also be a super class or implemented interface.- Parameters:
type- The type to set the default obfuscator for.defaultObfuscator- The default obfuscator to use.- Returns:
- This object.
- Throws:
NullPointerException- If the given type or obfuscator isnull.- Since:
- 1.1
-
requireObfuscatorAnnotation
Sets whether or not to require an annotation to provide an obfuscator forList,Set,CollectionandMapfields. If not, then anyList,Set,CollectionandMapfield with a generic type for which adefault obfuscatorwas specified will be obfuscated during deserialization. The default isfalse.- Parameters:
requireObfuscatorAnnotation-trueto require an annotation to provide an obfuscator, orfalseto use default obfuscators if present.- Returns:
- This object.
- Since:
- 1.1
-
withDefaultCharacterRepresentation
public ObfuscationModule.Builder withDefaultCharacterRepresentation(Class<?> type, CharacterRepresentationProvider defaultProvider) Sets the default character representation provider to use for a specific type, in case no character representation provider could be found from annotations. This type should be the generic type of anyObfuscated,List,Set,CollectionorMap. It doesn't need to be the exact type; it can also be a super class or implemented interface.By default, the following character representation providers are already registered:
CharacterRepresentationProvider.BooleanArrayToStringforboolean[]CharacterRepresentationProvider.CharArrayToStringforchar[]CharacterRepresentationProvider.ByteArrayToStringforbyte[]CharacterRepresentationProvider.ShortArrayToStringforshort[]CharacterRepresentationProvider.IntArrayToStringforint[]CharacterRepresentationProvider.LongArrayToStringforlong[]CharacterRepresentationProvider.FloatArrayToStringforfloat[]CharacterRepresentationProvider.DoubleArrayToStringfordouble[]CharacterRepresentationProvider.ObjectArrayToStringforObject[]
- Parameters:
type- The type to set the default obfuscator for.defaultProvider- The default character representation provider to use.- Returns:
- This object.
- Throws:
NullPointerException- If the given type or character representation provider isnull.- Since:
- 1.1
-
build
Creates a newObfuscationModulewith the current settings of this builder.- Returns:
- The created
ObfuscationModule.
-