Interface JSONObfuscator.Builder
- All Known Subinterfaces:
JSONObfuscator.LimitConfigurer,JSONObfuscator.PropertyConfigurer
- Enclosing class:
- JSONObfuscator
JSONObfuscators.- Author:
- Rob Spoor
-
Method Summary
Modifier and TypeMethodDescriptiondefault JSONObfuscator.BuilderIndicates that by default properties will be obfuscated if they are JSON objects or arrays (default).build()Creates a newJSONObfuscatorwith the properties and obfuscators added to this builder.Sets the default case sensitivity for new properties toCaseSensitivity.CASE_INSENSITIVE.Sets the default case sensitivity for new properties toCaseSensitivity.CASE_SENSITIVE.default JSONObfuscator.BuilderIndicates that by default properties will not be obfuscated if they are JSON arrays.default JSONObfuscator.BuilderIndicates that by default properties will not be obfuscated if they are JSON objects.forArraysByDefault(JSONObfuscator.PropertyConfigurer.ObfuscationMode obfuscationMode) Indicates how to handle properties if they are JSON arrays.forObjectsByDefault(JSONObfuscator.PropertyConfigurer.ObfuscationMode obfuscationMode) Indicates how to handle properties if they are JSON objects.default JSONObfuscator.BuilderIndicates that by default properties will be obfuscated if they are JSON arrays (default).default JSONObfuscator.BuilderIndicates that by default properties will be obfuscated if they are JSON objects (default).limitTo(long limit) Sets the limit for the obfuscated result.default JSONObfuscator.BuilderIndicates that by default properties will not be obfuscated if they are JSON objects or arrays.default <R> Rtransform(Function<? super JSONObfuscator.Builder, ? extends R> f) This method allows the application of a function to this builder.withJacksonVersion(JacksonVersion jacksonVersion) Sets the Jackson version to use.withMalformedJSONWarning(String warning) Sets the warning to include if aStreamReadExceptionis thrown.withProperty(String property, Obfuscator obfuscator) Adds a property to obfuscate.withProperty(String property, Obfuscator obfuscator, CaseSensitivity caseSensitivity) Adds a property to obfuscate.
-
Method Details
-
withProperty
Adds a property to obfuscate. This method is an alias forwithProperty(String, Obfuscator, CaseSensitivity)with the last specified default case sensitivity usingcaseSensitiveByDefault()orcaseInsensitiveByDefault(). The default isCaseSensitivity.CASE_SENSITIVE.- Parameters:
property- The name of the property.obfuscator- The obfuscator to use for obfuscating the property.- Returns:
- An object that can be used to configure the property, or continue building
JSONObfuscators. - Throws:
NullPointerException- If the given property name or obfuscator isnull.IllegalArgumentException- If a property with the same name and the same case sensitivity was already added.
-
withProperty
JSONObfuscator.PropertyConfigurer withProperty(String property, Obfuscator obfuscator, CaseSensitivity caseSensitivity) Adds a property to obfuscate.- Parameters:
property- The name of the property.obfuscator- The obfuscator to use for obfuscating the property.caseSensitivity- The case sensitivity for the property.- Returns:
- An object that can be used to configure the property, or continue building
JSONObfuscators. - Throws:
NullPointerException- If the given property name, obfuscator or case sensitivity isnull.IllegalArgumentException- If a property with the same name and the same case sensitivity was already added.
-
caseSensitiveByDefault
JSONObfuscator.Builder caseSensitiveByDefault()Sets the default case sensitivity for new properties toCaseSensitivity.CASE_SENSITIVE. This is the default setting.Note that this will not change the case sensitivity of any property that was already added.
- Returns:
- This object.
-
caseInsensitiveByDefault
JSONObfuscator.Builder caseInsensitiveByDefault()Sets the default case sensitivity for new properties toCaseSensitivity.CASE_INSENSITIVE.Note that this will not change the case sensitivity of any property that was already added.
- Returns:
- This object.
-
scalarsOnlyByDefault
Indicates that by default properties will not be obfuscated if they are JSON objects or arrays. This method is shorthand for calling bothexcludeObjectsByDefault()andexcludeArraysByDefault().Note that this will not change what will be obfuscated for any property that was already added.
- Returns:
- This object.
-
excludeObjectsByDefault
Indicates that by default properties will not be obfuscated if they are JSON objects. This method is an alias forforObjectsByDefault(ObfuscationMode)in combination withJSONObfuscator.PropertyConfigurer.ObfuscationMode.EXCLUDE.Note that this will not change what will be obfuscated for any property that was already added.
- Returns:
- This object.
-
excludeArraysByDefault
Indicates that by default properties will not be obfuscated if they are JSON arrays. This method is an alias forforArraysByDefault(ObfuscationMode)in combination withJSONObfuscator.PropertyConfigurer.ObfuscationMode.EXCLUDE.Note that this will not change what will be obfuscated for any property that was already added.
- Returns:
- This object.
-
allByDefault
Indicates that by default properties will be obfuscated if they are JSON objects or arrays (default). This method is shorthand for calling bothincludeObjectsByDefault()andincludeArraysByDefault().Note that this will not change what will be obfuscated for any property that was already added.
- Returns:
- This object.
-
includeObjectsByDefault
Indicates that by default properties will be obfuscated if they are JSON objects (default). This method is an alias forforObjectsByDefault(ObfuscationMode)in combination withJSONObfuscator.PropertyConfigurer.ObfuscationMode.OBFUSCATE.Note that this will not change what will be obfuscated for any property that was already added.
- Returns:
- This object.
-
includeArraysByDefault
Indicates that by default properties will be obfuscated if they are JSON arrays (default). This method is an alias forforArraysByDefault(ObfuscationMode)in combination withJSONObfuscator.PropertyConfigurer.ObfuscationMode.OBFUSCATE.Note that this will not change what will be obfuscated for any property that was already added.
- Returns:
- This object.
-
forObjectsByDefault
JSONObfuscator.Builder forObjectsByDefault(JSONObfuscator.PropertyConfigurer.ObfuscationMode obfuscationMode) Indicates how to handle properties if they are JSON objects. The default isJSONObfuscator.PropertyConfigurer.ObfuscationMode.OBFUSCATE. This can be overridden per property usingJSONObfuscator.PropertyConfigurer.forObjects(ObfuscationMode)Note that this will not change what will be obfuscated for any property that was already added.
- Parameters:
obfuscationMode- The obfuscation mode that determines how to handle properties.- Returns:
- This object.
- Throws:
NullPointerException- If the given obfuscation mode isnull.- Since:
- 1.3
-
forArraysByDefault
JSONObfuscator.Builder forArraysByDefault(JSONObfuscator.PropertyConfigurer.ObfuscationMode obfuscationMode) Indicates how to handle properties if they are JSON arrays. The default isJSONObfuscator.PropertyConfigurer.ObfuscationMode.OBFUSCATE. This can be overridden per property usingJSONObfuscator.PropertyConfigurer.forArrays(ObfuscationMode)Note that this will not change what will be obfuscated for any property that was already added.
- Parameters:
obfuscationMode- The obfuscation mode that determines how to handle properties.- Returns:
- This object.
- Throws:
NullPointerException- If the given obfuscation mode isnull.- Since:
- 1.3
-
withMalformedJSONWarning
Sets the warning to include if aStreamReadExceptionis thrown. This can be used to override the default message. Usenullto omit the warning.- Parameters:
warning- The warning to include.- Returns:
- This object.
-
withJacksonVersion
Sets the Jackson version to use. This method should only be called if more than one Jackson version is available.If a version is set that is not available, calling
build()will fail.- Parameters:
jacksonVersion- The Jackson version to use.- Returns:
- This object.
- Throws:
NullPointerException- If the given Jackson version isnull.- Since:
- 2.0
-
limitTo
Sets the limit for the obfuscated result.- Parameters:
limit- The limit to use.- Returns:
- An object that can be used to configure the handling when the obfuscated result exceeds a pre-defined limit,
or continue building
JSONObfuscators. - Throws:
IllegalArgumentException- If the given limit is negative.- Since:
- 1.1
-
transform
This method allows the application of a function to this builder.Any exception thrown by the function will be propagated to the caller.
- Type Parameters:
R- The type of the result of the function.- Parameters:
f- The function to apply.- Returns:
- The result of applying the function to this builder.
-
build
JSONObfuscator build()Creates a newJSONObfuscatorwith the properties and obfuscators added to this builder.- Returns:
- The created
JSONObfuscator.
-