Class RequirementResult
java.lang.Object
net.apartium.cocoabeans.commands.requirements.RequirementResult
Represents the result of a requirement check
This class encapsulates whether a requirement has been met, and optionally provides an error response and additional values if the requirement was met
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a value associated with a requirement result. -
Method Summary
Modifier and TypeMethodDescriptionstatic RequirementResulterror(BadCommandResponse error) Creates aRequirementResultrepresenting an error condition.getError()Returns the error response associated with this result.Returns the optional values associated with this result.booleanhasError()Checks whether there is an error associated with this result.static RequirementResultmeet()Creates aRequirementResultindicating that the requirement has been met without additional values.static RequirementResultmeet(RequirementResult.Value... values) Creates aRequirementResultindicating that the requirement has been met with optional values.booleanIndicates whether the requirement has been met.static RequirementResult.ValueCreates aValuefrom the specified value.static RequirementResult.ValueCreates aValuefrom the specified value and class.
-
Method Details
-
getError
Returns the error response associated with this result.- Returns:
- the error response, or
nullif no error
-
hasError
public boolean hasError()Checks whether there is an error associated with this result.- Returns:
trueif there is an error,falseotherwise
-
meetRequirement
public boolean meetRequirement()Indicates whether the requirement has been met.- Returns:
trueif the requirement is met,falseotherwise
-
getValues
Returns the optional values associated with this result.- Returns:
- optional values associated with this result
-
error
Creates aRequirementResultrepresenting an error condition.- Parameters:
error- the error response to be associated with this result- Returns:
- a new
RequirementResultinstance with the specified error
-
meet
Creates aRequirementResultindicating that the requirement has been met without additional values.- Returns:
- a new
RequirementResultinstance indicating the requirement is met
-
meet
Creates aRequirementResultindicating that the requirement has been met with optional values.- Parameters:
values- optional values associated with the result- Returns:
- a new
RequirementResultinstance indicating the requirement is met with the specified values
-
valueOf
@AvailableSince("0.0.30") public static RequirementResult.Value valueOf(Object value, Class<?> clazz) Creates aValuefrom the specified value and class.- Parameters:
value- the valueclazz- the class of the value- Returns:
- a new
Valueinstance with the specified value and class type
-
valueOf
Creates aValuefrom the specified value.- Parameters:
value- the value- Returns:
- a new
Valueinstance with Object#getClass as class type
-