Package dev.blaauwendraad.masker.json
Record Class MaskingState.ReplacementOperation
java.lang.Object
java.lang.Record
dev.blaauwendraad.masker.json.MaskingState.ReplacementOperation
- Record Components:
startIndex
- index from which to start replacingendIndex
- index at which to stop replacingmaskLength
- length of the mask to applymaskByte
- 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
ConstructorsConstructorDescriptionReplacementOperation
(int startIndex, int endIndex, int maskLength, byte maskByte) Creates an instance of aReplacementOperation
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
The difference between the mask length and the length of the target value to replace.int
endIndex()
Returns the value of theendIndex
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.byte
maskByte()
Returns the value of themaskByte
record component.int
Returns the value of themaskLength
record component.int
Returns the value of thestartIndex
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
ReplacementOperation
public ReplacementOperation(int startIndex, int endIndex, int maskLength, byte maskByte) Creates an instance of aReplacementOperation
record class.- Parameters:
startIndex
- the value for thestartIndex
record componentendIndex
- the value for theendIndex
record componentmaskLength
- the value for themaskLength
record componentmaskByte
- the value for themaskByte
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
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. -
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. -
equals
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 '=='. -
startIndex
public int startIndex()Returns the value of thestartIndex
record component.- Returns:
- the value of the
startIndex
record component
-
endIndex
public int endIndex()Returns the value of theendIndex
record component.- Returns:
- the value of the
endIndex
record component
-
maskLength
public int maskLength()Returns the value of themaskLength
record component.- Returns:
- the value of the
maskLength
record component
-
maskByte
public byte maskByte()Returns the value of themaskByte
record component.- Returns:
- the value of the
maskByte
record component
-