Record Class InvocationOutcome<T>

java.lang.Object
java.lang.Record
me.ehp246.aufjms.core.reflection.InvocationOutcome<T>

public record InvocationOutcome<T>(T returned, Throwable thrown, boolean hasReturned) extends Record
Since:
1.0
Author:
Lei Yang
  • Constructor Details

    • InvocationOutcome

      public InvocationOutcome(T returned, Throwable thrown, boolean hasReturned)
      Creates an instance of a InvocationOutcome record class.
      Parameters:
      returned - the value for the returned record component
      thrown - the value for the thrown record component
      hasReturned - the value for the hasReturned record component
  • Method Details

    • returned

      public static <T> InvocationOutcome<T> returned(T returned)
    • thrown

      public static <T> InvocationOutcome<T> thrown(Throwable thrown)
    • invoke

      public static <T> InvocationOutcome<T> invoke(Callable<T> callable)
    • hasThrown

      public boolean hasThrown()
    • outcomeValue

      public Object outcomeValue()
    • optionalReturned

      public Optional<T> optionalReturned()
    • 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.
    • returned

      public T returned()
      Returns the value of the returned record component.
      Returns:
      the value of the returned record component
    • thrown

      public Throwable thrown()
      Returns the value of the thrown record component.
      Returns:
      the value of the thrown record component
    • hasReturned

      public boolean hasReturned()
      Returns the value of the hasReturned record component.
      Returns:
      the value of the hasReturned record component