Record Class StringScope

java.lang.Object
java.lang.Record
net.luis.utils.io.reader.StringScope
Record Components:
open - The opening character of the scope
close - The closing character of the scope

public record StringScope(char open, char close) extends Record
A record to define a string scope with an opening and a closing character.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StringScope
    Constant string scope for angle brackets.
    private final char
    The field for the close record component.
    static final StringScope
    Constant string scope for curly brackets.
    private final char
    The field for the open record component.
    static final StringScope
    Constant string scope for parentheses.
    static final Map<Character,Character>
    A map that stores all created scopes.
    The key is the opening character and the value is the closing character.
    static final StringScope
    Constant string scope for square brackets.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StringScope(char open, char close)
    Constructs a new string scope with the given opening and closing character.
  • Method Summary

    Modifier and Type
    Method
    Description
    char
    Returns the value of the close record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    char
    Returns the value of the open record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • open

      private final char open
      The field for the open record component.
    • close

      private final char close
      The field for the close record component.
    • SCOPE_REGISTRY

      public static final Map<Character,Character> SCOPE_REGISTRY
      A map that stores all created scopes.
      The key is the opening character and the value is the closing character.
    • PARENTHESES

      public static final StringScope PARENTHESES
      Constant string scope for parentheses.
    • CURLY_BRACKETS

      public static final StringScope CURLY_BRACKETS
      Constant string scope for curly brackets.
    • SQUARE_BRACKETS

      public static final StringScope SQUARE_BRACKETS
      Constant string scope for square brackets.
    • ANGLE_BRACKETS

      public static final StringScope ANGLE_BRACKETS
      Constant string scope for angle brackets.
  • Constructor Details

    • StringScope

      public StringScope(char open, char close)
      Constructs a new string scope with the given opening and closing character.
      Parameters:
      open - The opening character
      close - The closing character
      Throws:
      IllegalArgumentException - If the opening and closing character are the same
  • Method Details

    • toString

      public final 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
    • hashCode

      public final 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
    • equals

      public final boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • open

      public char open()
      Returns the value of the open record component.
      Returns:
      the value of the open record component
    • close

      public char close()
      Returns the value of the close record component.
      Returns:
      the value of the close record component