Package icyllis.modernui.util
Record Class StringView
java.lang.Object
java.lang.Record
icyllis.modernui.util.StringView
- All Implemented Interfaces:
GetChars,CharSequence,Comparable<CharSequence>
@Experimental
public record StringView(String string, int offset, int length)
extends Record
implements Comparable<CharSequence>, CharSequence, GetChars
Special class that represents a region of a String, used for fast
HashMap lookup and memory comparison.
-
Constructor Summary
ConstructorsConstructorDescriptionStringView(String string, int offset, int length) Creates an instance of aStringViewrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) intbooleanIndicates whether some other object is "equal to" this one.voidgetChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) inthashCode()Returns a hash code value for this object.intlength()Returns the value of thelengthrecord component.intoffset()Returns the value of theoffsetrecord component.string()Returns the value of thestringrecord component.subSequence(int start, int end) toString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
StringView
Creates an instance of aStringViewrecord class.- Parameters:
string- the value for thestringrecord componentoffset- the value for theoffsetrecord componentlength- the value for thelengthrecord component
-
-
Method Details
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
getChars
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) -
hashCode
public 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 '=='. -
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:
toStringin interfaceCharSequence- Specified by:
toStringin classRecord- Returns:
- a string representation of this object
-
compareTo
- Specified by:
compareToin interfaceComparable<CharSequence>
-
string
Returns the value of thestringrecord component.- Returns:
- the value of the
stringrecord component
-
offset
public int offset()Returns the value of theoffsetrecord component.- Returns:
- the value of the
offsetrecord component
-
length
public int length()Returns the value of thelengthrecord component.- Specified by:
lengthin interfaceCharSequence- Returns:
- the value of the
lengthrecord component
-