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 replacingmask
- byte array mask to use as replacement for the valuemaskRepeat
- 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
ConstructorsConstructorDescriptionReplacementOperation
(int startIndex, int endIndex, byte[] mask, int maskRepeat) 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[]
mask()
Returns the value of themask
record component.int
Returns the value of themaskRepeat
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, byte[] mask, int maskRepeat) Creates an instance of aReplacementOperation
record class.- Parameters:
startIndex
- the value for thestartIndex
record componentendIndex
- the value for theendIndex
record componentmask
- the value for themask
record componentmaskRepeat
- the value for themaskRepeat
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components 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
-
mask
public byte[] mask()Returns the value of themask
record component.- Returns:
- the value of the
mask
record component
-
maskRepeat
public int maskRepeat()Returns the value of themaskRepeat
record component.- Returns:
- the value of the
maskRepeat
record component
-