Record Class AsciiString

java.lang.Object
java.lang.Record
org.jgroups.util.AsciiString
Record Components:
val - The value as a byte array
All Implemented Interfaces:
Comparable<AsciiString>

public record AsciiString(byte[] val) extends Record implements Comparable<AsciiString>
Simple string implemented as a byte[] array. Each character's higher 8 bits are truncated and only the lower 8 bits are stored. AsciiString is mutable for efficiency reasons, but the chars array should never be changed !
Since:
3.5
Author:
Bela Ban
  • Constructor Details

    • AsciiString

      public AsciiString(String str)
    • AsciiString

      public AsciiString(AsciiString str)
    • AsciiString

      public AsciiString(byte[] val)
      Creates an instance of a AsciiString record class.
      Parameters:
      val - the value for the val record component
  • Method Details

    • length

      public int length()
    • compareTo

      public int compareTo(AsciiString str)
      Specified by:
      compareTo in interface Comparable<AsciiString>
    • equals

      public boolean equals(Object obj)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      obj - the object with which to compare
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • equals

      public boolean equals(byte[] other)
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String 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 class Record
      Returns:
      a string representation of this object
    • val

      public byte[] val()
      Returns the value of the val record component.
      Returns:
      the value of the val record component