Package org.ujorm.tools.common
Class UnicodeCharacter
java.lang.Object
org.ujorm.tools.common.UnicodeCharacter
- All Implemented Interfaces:
Serializable,Comparable<UnicodeCharacter>
public final class UnicodeCharacter
extends Object
implements Comparable<UnicodeCharacter>, Serializable
Represents one valid Unicode character (code point).
Immutable and type-safe alternative to the primitive `int` code point.
- Author:
- Pavel Ponec, https://github.com/pponec/
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintA character numberintcompareTo(UnicodeCharacter other) Compare two objectsbooleanequals(char c) Checks whether this UnicodeCharacter is equal to the given primitive char.booleaninthashCode()static UnicodeCharactercharAt(int index, CharSequence text) Get a Unicode character at the indexstatic intReturns count of the Unicode characters of the textbooleanisDigit()booleanisEmoji()booleanisLetter()booleanstatic UnicodeCharacterof(int codePoint) The factory method allows to generate different implementations in the future according to the parameter.static Stream<UnicodeCharacter>stream(InputStream inputStream, Charset charset) Create a Stream of the UnicodeCharacter objectsstatic Stream<UnicodeCharacter>stream(CharSequence text) Create a Stream of the UnicodeCharacter objectstoString()voidWrites this UnicodeCharacter to the given Writer.
-
Method Details
-
codePoint
public int codePoint()A character number -
isSupplementary
public boolean isSupplementary() -
isEmoji
public boolean isEmoji() -
isLetter
public boolean isLetter() -
isDigit
public boolean isDigit() -
toString
-
equals
public boolean equals(char c) Checks whether this UnicodeCharacter is equal to the given primitive char.- Parameters:
c- the primitive char to compare with- Returns:
- true if this UnicodeCharacter represents the same character as the given char
-
equals
-
hashCode
public int hashCode() -
writeTo
Writes this UnicodeCharacter to the given Writer.- Parameters:
writer- the Writer to write the character to- Throws:
IOException- if an I/O error occurs
-
stream
Create a Stream of the UnicodeCharacter objects -
stream
Create a Stream of the UnicodeCharacter objects -
of
The factory method allows to generate different implementations in the future according to the parameter. -
charAt
Get a Unicode character at the index- Parameters:
index- Index of the character in the text, negative value takes characters from the end.text- Text resource.- Returns:
- Unicode character object.
- See Also:
-
charCount
Returns count of the Unicode characters of the text -
compareTo
Compare two objects- Specified by:
compareToin interfaceComparable<UnicodeCharacter>
-