Class FieldScrubber<T>

java.lang.Object
org.approvej.scrub.FieldScrubber<T>
Type Parameters:
T - the type of value to scrub
All Implemented Interfaces:
Function<T,T>, UnaryOperator<T>, Scrubber<T>

@NullMarked public class FieldScrubber<T> extends Object implements Scrubber<T>
Generic Scrubber to set the value of a certain field via reflection.

Note that this requires that the field is generally mutable. Fields that are declared final will cause a ScrubbingError when this is applied.

  • Method Details

    • apply

      public T apply(T value)
      Scrubs the given value.
      Specified by:
      apply in interface Function<T,T>
      Parameters:
      value - the object to be scrubbed
      Returns:
      the scrubbed object
      Throws:
      ScrubbingError - if the field cannot be edited
    • replacement

      public FieldScrubber<T> replacement(Object replacement)
      Sets the replacement Object.
      Parameters:
      replacement - the new replacement Object
      Returns:
      this