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 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

      public String toString()
      Overrides:
      toString in class Object
    • 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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeTo

      public void writeTo(Writer writer) throws IOException
      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

      public static Stream<UnicodeCharacter> stream(CharSequence text)
      Create a Stream of the UnicodeCharacter objects
    • stream

      public static Stream<UnicodeCharacter> stream(InputStream inputStream, Charset charset)
      Create a Stream of the UnicodeCharacter objects
    • of

      public static UnicodeCharacter of(int codePoint)
      The factory method allows to generate different implementations in the future according to the parameter.
    • charAt

      public static UnicodeCharacter charAt(int index, CharSequence text)
      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

      public static int charCount(String text)
      Returns count of the Unicode characters of the text
    • compareTo

      public int compareTo(UnicodeCharacter other)
      Compare two objects
      Specified by:
      compareTo in interface Comparable<UnicodeCharacter>