Record Class TryParser.Failure<R extends @NonNull Object,T extends @NonNull Object>

java.lang.Object
java.lang.Record
dev.sympho.modular_commands.utils.parse.TryParser.Failure<R,T>
Type Parameters:
R - The raw type.
T - The parsed type.
Record Components:
raw - The raw value.
error - The parsing error.
All Implemented Interfaces:
TryParser.Result<R,T>
Enclosing interface:
TryParser<R extends @NonNull Object,T extends @NonNull Object>

public static record TryParser.Failure<R extends @NonNull Object,T extends @NonNull Object>(R extends @NonNull Object raw, InvalidArgumentException error) extends Record implements TryParser.Result<R,T>
A result in which the item was invalid.
Since:
1.0
  • Constructor Details

    • Failure

      public Failure(R raw, InvalidArgumentException error)
      Creates an instance of a Failure record class.
      Parameters:
      raw - the value for the raw record component
      error - the value for the error record component
  • Method Details

    • item

      public @Nullable T item()
      Description copied from interface: TryParser.Result
      The parsed item, if parsed successfully.
      Specified by:
      item in interface TryParser.Result<R extends @NonNull Object,T extends @NonNull Object>
      Returns:
      The parsed item, or null if the item was invalid.
      Implementation Requirements:
      Always returns null.
    • 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 Objects::equals(Object,Object).
      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.
    • raw

      public R raw()
      Returns the value of the raw record component.
      Specified by:
      raw in interface TryParser.Result<R extends @NonNull Object,T extends @NonNull Object>
      Returns:
      the value of the raw record component
    • error

      public InvalidArgumentException error()
      Returns the value of the error record component.
      Specified by:
      error in interface TryParser.Result<R extends @NonNull Object,T extends @NonNull Object>
      Returns:
      the value of the error record component