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 aStringView
record class. -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) int
boolean
Indicates whether some other object is "equal to" this one.void
getChars
(int srcBegin, int srcEnd, char[] dst, int dstBegin) int
hashCode()
Returns a hash code value for this object.int
length()
Returns the value of thelength
record component.int
offset()
Returns the value of theoffset
record component.string()
Returns the value of thestring
record 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, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
StringView
Creates an instance of aStringView
record class.- Parameters:
string
- the value for thestring
record componentoffset
- the value for theoffset
record componentlength
- the value for thelength
record component
-
-
Method Details
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in 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:
toString
in interfaceCharSequence
- Specified by:
toString
in classRecord
- Returns:
- a string representation of this object
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CharSequence>
-
string
Returns the value of thestring
record component.- Returns:
- the value of the
string
record component
-
offset
public int offset()Returns the value of theoffset
record component.- Returns:
- the value of the
offset
record component
-
length
public int length()Returns the value of thelength
record component.- Specified by:
length
in interfaceCharSequence
- Returns:
- the value of the
length
record component
-