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 aReplacementOperationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintThe difference between the mask length and the length of the target value to replace.intendIndex()Returns the value of theendIndexrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.bytemaskByte()Returns the value of themaskByterecord component.intReturns the value of themaskLengthrecord component.intReturns the value of thestartIndexrecord component.final StringtoString()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 aReplacementOperationrecord class.- Parameters:
startIndex- the value for thestartIndexrecord componentendIndex- the value for theendIndexrecord componentmaskLength- the value for themaskLengthrecord componentmaskByte- the value for themaskByterecord 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 thestartIndexrecord component.- Returns:
- the value of the
startIndexrecord component
-
endIndex
public int endIndex()Returns the value of theendIndexrecord component.- Returns:
- the value of the
endIndexrecord component
-
maskLength
public int maskLength()Returns the value of themaskLengthrecord component.- Returns:
- the value of the
maskLengthrecord component
-
maskByte
public byte maskByte()Returns the value of themaskByterecord component.- Returns:
- the value of the
maskByterecord component
-