public static final class Obfuscator.PortionBuilder extends Object
keepAtStart(x)
and keepAtEnd(y)
will, for input s
,
obfuscate all characters in the range x
(inclusive) to s.length()
- y
(exclusive).
If this range is empty, such an obfuscator will not obfuscate anything, unless if withFixedTotalLength(int)
or
withFixedLength(int)
is specified.Modifier and Type | Method and Description |
---|---|
Obfuscator.PortionBuilder |
atLeastFromEnd(int count)
Sets the minimum number of characters from the end that need to be obfuscated.
|
Obfuscator.PortionBuilder |
atLeastFromStart(int count)
Sets the minimum number of characters from the start that need to be obfuscated.
|
Obfuscator |
build()
Creates an immutable obfuscator with the current settings of this builder.
|
Obfuscator.PortionBuilder |
keepAtEnd(int count)
Sets the number of characters at the end that created obfuscators will skip when obfuscating.
|
Obfuscator.PortionBuilder |
keepAtStart(int count)
Sets the number of characters at the start that created obfuscators will skip when obfuscating.
|
<R> R |
transform(Function<? super Obfuscator.PortionBuilder,? extends R> f)
This method allows the application of a function to this builder.
|
Obfuscator.PortionBuilder |
withDefaults()
Specifies that the default settings should be restored.
|
Obfuscator.PortionBuilder |
withFixedLength(int fixedObfuscatedLength)
Deprecated.
The total length of obfuscated contents can vary when using this setting, making it possible in certain cases to find the
original value that was obfuscated. Use
withFixedTotalLength(int) instead. |
Obfuscator.PortionBuilder |
withFixedTotalLength(int fixedTotalLength)
Sets or removes the fixed total length to use for obfuscated contents.
|
Obfuscator.PortionBuilder |
withMaskChar(char maskChar)
Sets the char that created obfuscators use for obfuscating.
|
public Obfuscator.PortionBuilder keepAtStart(int count)
count
- The number of characters to skip. The default is 0
.IllegalArgumentException
- If the count is negative.public Obfuscator.PortionBuilder keepAtEnd(int count)
count
- The number of characters to skip. The default is 0
.IllegalArgumentException
- If the count is negative.public Obfuscator.PortionBuilder atLeastFromStart(int count)
keepAtStart(int)
or keepAtEnd(int)
.count
- The minimum number of characters to obfuscate. The default is 0
.IllegalArgumentException
- If the count is negative.public Obfuscator.PortionBuilder atLeastFromEnd(int count)
keepAtStart(int)
or keepAtEnd(int)
.count
- The minimum number of characters to obfuscate. The default is 0
.IllegalArgumentException
- If the count is negative.public Obfuscator.PortionBuilder withFixedTotalLength(int fixedTotalLength)
mask characters
added until this total length has been reached.
Note: when used in combination with keepAtStart(int)
and/or keepAtEnd(int)
, this total length must be at least the sum
of both other values. When used in combination with both, parts of the input may be repeated in the obfuscated content if the input's
length is less than the combined number of characters to keep.
fixedTotalLength
- The fixed total length for obfuscated contents, or a negative value to use the actual length of the input.
The default is -1
.@Deprecated public Obfuscator.PortionBuilder withFixedLength(int fixedObfuscatedLength)
withFixedTotalLength(int)
instead.mask characters
to use for obfuscating.
This setting will be ignored if the fixed total length
is set.
fixedObfuscatedLength
- The fixed number of mask characters, or a negative value to use the actual length of the input.
The default is -1
.public Obfuscator.PortionBuilder withMaskChar(char maskChar)
maskChar
- The mask character. The default is *
.public Obfuscator.PortionBuilder withDefaults()
public <R> R transform(Function<? super Obfuscator.PortionBuilder,? extends R> f)
Any exception thrown by the function will be propagated to the caller.
R
- The type of the result of the function.f
- The function to apply.public Obfuscator build()
IllegalStateException
- If this builder is in an invalid state, for example if withFixedTotalLength(int)
is smaller than
keepAtStart(int)
and keepAtEnd(int)
combined.Copyright © 2020–2023. All rights reserved.