Record Class DefaultHandlingResult
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.network.rpc.defaults.handler.DefaultHandlingResult
- Record Components:
wasSuccessful- if the method invocation was successful or ended by an exception.invocationResult- the result of the method invocation.invocationHandler- the handler which is responsible for the class the method wss invoked in.targetMethodInformation- the information of the method which was invoked.
- All Implemented Interfaces:
RPCHandler.HandlingResult
public record DefaultHandlingResult(boolean wasSuccessful, @Nullable Object invocationResult, @NonNull RPCHandler invocationHandler, @NonNull MethodInformation targetMethodInformation)
extends Record
implements RPCHandler.HandlingResult
Represents the result of a method invocation.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull RPCHandlerThe field for theinvocationHandlerrecord component.The field for theinvocationResultrecord component.private final @NonNull MethodInformationThe field for thetargetMethodInformationrecord component.private final booleanThe field for thewasSuccessfulrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHandlingResult(boolean wasSuccessful, @Nullable Object invocationResult, @NonNull RPCHandler invocationHandler, @NonNull MethodInformation targetMethodInformation) Creates an instance of aDefaultHandlingResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static RPCHandler.HandlingResultfailure(@NonNull MethodInformation information, @NonNull RPCHandler invocationHandler, @NonNull Throwable result) Constructs a new failed invocation result, indicating that an exception was thrown as the result of the method call.final inthashCode()Returns a hash code value for this object.Returns the value of theinvocationHandlerrecord component.Returns the value of theinvocationResultrecord component.static RPCHandler.HandlingResultsuccess(@NonNull MethodInformation methodInformation, @NonNull RPCHandler invocationHandler, @Nullable Object result) Constructs a new successful invocation result with the information provided.Returns the value of thetargetMethodInformationrecord component.final StringtoString()Returns a string representation of this record class.booleanReturns the value of thewasSuccessfulrecord component.
-
Field Details
-
wasSuccessful
private final boolean wasSuccessfulThe field for thewasSuccessfulrecord component. -
invocationResult
The field for theinvocationResultrecord component. -
invocationHandler
The field for theinvocationHandlerrecord component. -
targetMethodInformation
The field for thetargetMethodInformationrecord component.
-
-
Constructor Details
-
DefaultHandlingResult
public DefaultHandlingResult(boolean wasSuccessful, @Nullable @Nullable Object invocationResult, @NonNull @NonNull RPCHandler invocationHandler, @NonNull @NonNull MethodInformation targetMethodInformation) Creates an instance of aDefaultHandlingResultrecord class.- Parameters:
wasSuccessful- the value for thewasSuccessfulrecord componentinvocationResult- the value for theinvocationResultrecord componentinvocationHandler- the value for theinvocationHandlerrecord componenttargetMethodInformation- the value for thetargetMethodInformationrecord component
-
-
Method Details
-
success
@NonNull public static RPCHandler.HandlingResult success(@NonNull @NonNull MethodInformation methodInformation, @NonNull @NonNull RPCHandler invocationHandler, @Nullable @Nullable Object result) Constructs a new successful invocation result with the information provided.- Parameters:
methodInformation- the information of the method which was invoked.invocationHandler- the handler which is responsible for the class the method wss invoked in.result- the result of the method invocation.- Returns:
- the constructed method invocation result.
- Throws:
NullPointerException- if either the given method information or handler is null.
-
failure
@NonNull public static RPCHandler.HandlingResult failure(@NonNull @NonNull MethodInformation information, @NonNull @NonNull RPCHandler invocationHandler, @NonNull @NonNull Throwable result) Constructs a new failed invocation result, indicating that an exception was thrown as the result of the method call.- Parameters:
information- the information of the method which was invoked.invocationHandler- the handler which is responsible for the class the method wss invoked in.result- the exception which was thrown during the method invocation.- Returns:
- the constructed method invocation result.
- Throws:
NullPointerException- if either the given method information, handler or exception is null.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
wasSuccessful
public boolean wasSuccessful()Returns the value of thewasSuccessfulrecord component.- Specified by:
wasSuccessfulin interfaceRPCHandler.HandlingResult- Returns:
- the value of the
wasSuccessfulrecord component
-
invocationResult
Returns the value of theinvocationResultrecord component.- Specified by:
invocationResultin interfaceRPCHandler.HandlingResult- Returns:
- the value of the
invocationResultrecord component
-
invocationHandler
Returns the value of theinvocationHandlerrecord component.- Specified by:
invocationHandlerin interfaceRPCHandler.HandlingResult- Returns:
- the value of the
invocationHandlerrecord component
-
targetMethodInformation
Returns the value of thetargetMethodInformationrecord component.- Specified by:
targetMethodInformationin interfaceRPCHandler.HandlingResult- Returns:
- the value of the
targetMethodInformationrecord component
-