Package org.apache.juneau.config.mod
Class Mod
java.lang.Object
org.apache.juneau.config.mod.Mod
- Direct Known Subclasses:
XorEncodeMod
Specifies an entry modifier that is used to encode during write and decode during read of config entries.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionApplies this modification to the specified entry value.final String
Applies this modification to the specified entry value if it isn't already applied.final String
Removes this modification from the specified entry value if it is applied.char
getId()
Returns the modifier identifier character.boolean
Detects whether this modification has been applied.Removes this modification to the specified entry value.
-
Field Details
-
NO_OP
A no-op modifier.
-
-
Constructor Details
-
Mod
public Mod(char id, Function<String, String> applyFunction, Function<String, String> removeFunction, Function<String, Boolean> detectFunction) Constructor.- Parameters:
id
- The character identifier.applyFunction
- The function to apply when writing an entry. Can benull if you override theapply(String)
method.removeFunction
- The function to apply when reading an entry. Can benull if you override theremove(String)
method.detectFunction
- The function to apply to detect whether the modification has been made. Can benull if you override theisApplied(String)
method.
-
-
Method Details
-
getId
Returns the modifier identifier character.- Returns:
- The modifier identifier character.
-
isApplied
Detects whether this modification has been applied.- Parameters:
value
- The entry value being tested. Will never benull .- Returns:
true if the modification has been made to the entry.
-
apply
Applies this modification to the specified entry value.Will only be called if
isApplied(String)
returnsfalse .- Parameters:
value
- The entry value being written. Will never benull .- Returns:
- The modified value.
-
remove
Removes this modification to the specified entry value.Will only be called if
isApplied(String)
returnstrue .- Parameters:
value
- The entry value being read. Will never benull .- Returns:
- The unmodified value.
-
doApply
Applies this modification to the specified entry value if it isn't already applied.- Parameters:
value
- The entry value being written. Will never benull .- Returns:
- The modified value.
-
doRemove
Removes this modification from the specified entry value if it is applied.- Parameters:
value
- The entry value being written. Will never benull .- Returns:
- The modified value.
-