Class Mod

java.lang.Object
org.apache.juneau.config.mod.Mod
Direct Known Subclasses:
XorEncodeMod

public class Mod extends Object
Specifies an entry modifier that is used to encode during write and decode during read of config entries.
  • Field Details

    • NO_OP

      public static final Mod 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 be null if you override the apply(String) method.
      removeFunction - The function to apply when reading an entry. Can be null if you override the remove(String) method.
      detectFunction - The function to apply to detect whether the modification has been made. Can be null if you override the isApplied(String) method.
  • Method Details

    • getId

      public char getId()
      Returns the modifier identifier character.
      Returns:
      The modifier identifier character.
    • isApplied

      public boolean isApplied(String value)
      Detects whether this modification has been applied.
      Parameters:
      value - The entry value being tested. Will never be null.
      Returns:
      true if the modification has been made to the entry.
    • apply

      public String apply(String value)
      Applies this modification to the specified entry value.

      Will only be called if isApplied(String) returns false.

      Parameters:
      value - The entry value being written. Will never be null.
      Returns:
      The modified value.
    • remove

      public String remove(String value)
      Removes this modification to the specified entry value.

      Will only be called if isApplied(String) returns true.

      Parameters:
      value - The entry value being read. Will never be null.
      Returns:
      The unmodified value.
    • doApply

      public final String doApply(String value)
      Applies this modification to the specified entry value if it isn't already applied.
      Parameters:
      value - The entry value being written. Will never be null.
      Returns:
      The modified value.
    • doRemove

      public final String doRemove(String value)
      Removes this modification from the specified entry value if it is applied.
      Parameters:
      value - The entry value being written. Will never be null.
      Returns:
      The modified value.