Record Class CharArray

java.lang.Object
java.lang.Record
org.aspectj.org.eclipse.jdt.internal.compiler.util.CharArray
All Implemented Interfaces:
Comparable<CharArray>

public record CharArray(char[] key) extends Record implements Comparable<CharArray>
Wrapper around char arrays that can be used as a key in a Map or Set.

The hashCode() and equals(Object) method will work with the underlying array using Arrays.hashCode and Arrays.equals.

  • Constructor Summary

    Constructors
    Constructor
    Description
    CharArray(char[] key)
    Creates an instance of a CharArray record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
    Indicates whether some other object is "equal to" this one.
    char[]
     
    int
    Returns a hash code value for this object.
    char[]
    key()
    Returns the value of the key record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CharArray

      public CharArray(char[] key)
      Creates an instance of a CharArray record class.
      Parameters:
      key - the value for the key record component
  • Method Details

    • compareTo

      public int compareTo(CharArray o)
      Specified by:
      compareTo in interface Comparable<CharArray>
    • getKey

      public char[] getKey()
    • 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.
    • 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
    • key

      public char[] key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component