- java.lang.Object
-
- dev.netcode.util.Result<T>
-
- Type Parameters:
T- type of object the function should have returned
public class Result<T> extends java.lang.ObjectInstances of this class can be used when a function may encounter an error and wants to display the error message but you want to manually display it.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget()java.lang.StringgetError()booleanwasSuccessful()
-
-
-
Constructor Detail
-
Result
public Result(T value, java.lang.String error)
Instantiates Result and sets either the value or error.
Only one of both can be set, error is preferred to prevent unexpected behavior.- Parameters:
value- if successful or nullerror- if failed or null- Throws:
java.lang.IllegalArgumentException- in case both parameters are set to null
-
-
Method Detail
-
wasSuccessful
public boolean wasSuccessful()
- Returns:
- whether retrieving the result was successful
-
get
public T get()
- Returns:
- the result
-
getError
public java.lang.String getError()
- Returns:
- the error
-
-