Record Class MaskingState.ReplacementOperation

java.lang.Object
java.lang.Record
dev.blaauwendraad.masker.json.MaskingState.ReplacementOperation
Record Components:
startIndex - index from which to start replacing
endIndex - index at which to stop replacing
mask - byte array mask to use as replacement for the value
maskRepeat - number of times to repeat the mask (for cases when every character or digit is masked)
Enclosing class:
MaskingState

public static record MaskingState.ReplacementOperation(int startIndex, int endIndex, byte[] mask, int maskRepeat) extends Record
Represents a delayed replacement that requires resizing of the message byte array. In order to avoid resizing on every mask, we store the replacement operations in a list and apply them all at once at the end, thus making only a single resize operation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReplacementOperation(int startIndex, int endIndex, byte[] mask, int maskRepeat)
    Creates an instance of a ReplacementOperation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The difference between the mask length and the length of the target value to replace.
    int
    Returns the value of the endIndex record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    byte[]
    Returns the value of the mask record component.
    int
    Returns the value of the maskRepeat record component.
    int
    Returns the value of the startIndex record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ReplacementOperation

      public ReplacementOperation(int startIndex, int endIndex, byte[] mask, int maskRepeat)
      Creates an instance of a ReplacementOperation record class.
      Parameters:
      startIndex - the value for the startIndex record component
      endIndex - the value for the endIndex record component
      mask - the value for the mask record component
      maskRepeat - the value for the maskRepeat record component
  • Method Details

    • difference

      public int difference()
      The difference between the mask length and the length of the target value to replace. Used to calculate keep track of the offset during replacements.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • startIndex

      public int startIndex()
      Returns the value of the startIndex record component.
      Returns:
      the value of the startIndex record component
    • endIndex

      public int endIndex()
      Returns the value of the endIndex record component.
      Returns:
      the value of the endIndex record component
    • mask

      public byte[] mask()
      Returns the value of the mask record component.
      Returns:
      the value of the mask record component
    • maskRepeat

      public int maskRepeat()
      Returns the value of the maskRepeat record component.
      Returns:
      the value of the maskRepeat record component