Class Result<Type>
java.lang.Object
de.gustavblass.commons.Result<Type>
- Type Parameters:
Type
- The class of the operation's result.
Represents the outcome of an operation that is either successful or unsuccessful and may return an
elaborate result. If the operation was unsuccessful, the cause of failure may be specified.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
success
private final boolean successWhether the operation was successful. Success does not imply that an elaborateresult
was returned, and failure does not imply that no elaborate result was returned. -
result
The detailed outcome of the operation. Its presence does not imply that the operation was successful, and its absence does not imply that the operation was unsuccessful. -
cause
The reason why the operation failed, if any. If it is not present, this does not imply that the operation was successful (usegetSuccess()
for that).
-
-
Constructor Details
-
Result
public Result(boolean success) Creates a new result object with no elaborate return value. UseResult(boolean, Type)
if there is an elaborate return value that should be included.- Parameters:
success
- True if the operation was successful, false otherwise.- See Also:
-
Result
Creates a new result object.- Parameters:
success
- True if the operation was successful, false otherwise.result
- The elaborate return value of the operation. Must not be null. UseResult(boolean)
if there is no elaborate return value.- See Also:
-
Result
-
Result
Creates a new result object with acause
of failure.- Parameters:
success
- True if the operation was successful, false otherwise.result
- The elaborate return value of the operation.cause
- The reason why the operation failed.
-
-
Method Details
-
getSuccess
@Contract(pure=true) public boolean getSuccess()- Returns:
- Whether the operation was successful. If true, this does not imply that
getResult()
will return a non-empty value. If false, this does not imply thatgetResult()
will return an empty value.
-
getResult
-
getCause
- Returns:
- The reason why the operation failed, if any. If it is not present, this does not imply that the
operation was successful (use
getSuccess()
for that).
-
copy
-