Record Class MappingResult<T>

java.lang.Object
java.lang.Record
com.minecolonies.core.datalistener.util.MappingResult<T>
Type Parameters:
T - the type of entry.
Record Components:
success - whether the entry was successfully parsed or not.
item - the entry, if successfully parsed.
reason - the reason when failed.

public record MappingResult<T>(boolean success, T item, String reason) extends Record
Mapping result class for returning the entry + warnings.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MappingResult(boolean success, T item, String reason)
    Creates an instance of a MappingResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    static <T> MappingResult<T>
    fail(String reason)
    Create a FAIL mapping result, giving a failure reason.
    final int
    Returns a hash code value for this object.
    Returns the value of the item record component.
    static <T> MappingResult<T>
    ok(T item)
    Create an OK mapping result, giving the item entry.
    Returns the value of the reason record component.
    boolean
    Returns the value of the success 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
  • Constructor Details

    • MappingResult

      public MappingResult(boolean success, T item, String reason)
      Creates an instance of a MappingResult record class.
      Parameters:
      success - the value for the success record component
      item - the value for the item record component
      reason - the value for the reason record component
  • Method Details

    • ok

      public static <T> MappingResult<T> ok(T item)
      Create an OK mapping result, giving the item entry.
      Type Parameters:
      T - the type of entry.
      Parameters:
      item - the entry instance.
      Returns:
      the mapping result instance.
    • fail

      public static <T> MappingResult<T> fail(String reason)
      Create a FAIL mapping result, giving a failure reason.
      Type Parameters:
      T - the type of entry.
      Parameters:
      reason - the failure reason.
      Returns:
      the mapping result instance.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • success

      public boolean success()
      Returns the value of the success record component.
      Returns:
      the value of the success record component
    • item

      public T item()
      Returns the value of the item record component.
      Returns:
      the value of the item record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Returns:
      the value of the reason record component