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
maskLength - length of the mask to apply
maskByte - byte to use for the mask
Enclosing class:
MaskingState

public static record MaskingState.ReplacementOperation(int startIndex, int endIndex, int maskLength, byte maskByte) 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, int maskLength, byte maskByte)
    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 maskByte record component.
    int
    Returns the value of the maskLength 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, int maskLength, byte maskByte)
      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
      maskLength - the value for the maskLength record component
      maskByte - the value for the maskByte 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. All components in this record class 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
    • maskLength

      public int maskLength()
      Returns the value of the maskLength record component.
      Returns:
      the value of the maskLength record component
    • maskByte

      public byte maskByte()
      Returns the value of the maskByte record component.
      Returns:
      the value of the maskByte record component