Class ValidatedResult<T>
java.lang.Object
software.amazon.smithy.model.validation.ValidatedResult<T>
- Type Parameters:
T
- The type being created.
Represents the result of an operation and the
ValidationEvent
s
that occurred.-
Constructor Summary
ConstructorDescriptionValidatedResult
(T result, Collection<ValidationEvent> events) Deprecated.ValidatedResult
(T result, List<ValidationEvent> events) Creates a result with a value and events. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ValidatedResult<T>
empty()
Creates an empty ValidatedResult with no value and no events.static <T> ValidatedResult<T>
fromErrors
(Collection<ValidationEvent> events) Deprecated.static <T> ValidatedResult<T>
fromErrors
(List<ValidationEvent> events) Creates a new ValidatedResult with no values and a list ofValidationEvent
s.static <T> ValidatedResult<T>
fromValue
(T value) Creates a new ValidatedResult with a value and noValidationEvent
s.Get the optional result.Get the list ofValidationEvent
s associated with the result.getValidationEvents
(Severity severity) Get validation events of a particular severity.boolean
isBroken()
Checks if the result has any error or danger events..unwrap()
Get the result, but throw if there are any ERROR or DANGER events or if the result is empty.validate()
Get the optional result, and throw if there are any ERROR events.
-
Constructor Details
-
ValidatedResult
Creates a result with a value and events.- Parameters:
result
- Value to set.events
- Events to set.
-
ValidatedResult
Deprecated.
-
-
Method Details
-
fromErrors
Creates a new ValidatedResult with no values and a list ofValidationEvent
s.- Type Parameters:
T
- The type of value in the result.- Parameters:
events
- Validation events on the result.- Returns:
- Returns the created ValidatedResult.
-
fromErrors
Deprecated. -
fromValue
Creates a new ValidatedResult with a value and noValidationEvent
s.- Type Parameters:
T
- The type of value in the result.- Parameters:
value
- Result value,- Returns:
- Returns the created ValidatedResult.
-
empty
Creates an empty ValidatedResult with no value and no events.- Type Parameters:
T
- The type of value in the result.- Returns:
- Returns the created ValidatedResult.
-
getValidationEvents
Get the list ofValidationEvent
s associated with the result.- Returns:
- Returns the validation events.
-
getValidationEvents
Get validation events of a particular severity.- Parameters:
severity
- Severity to get.- Returns:
- Returns a list of events with the given severity.
-
getResult
Get the optional result.- Returns:
- Returns the optional result.
-
unwrap
Get the result, but throw if there are any ERROR or DANGER events or if the result is empty.- Returns:
- Returns the result.
- Throws:
ValidatedResultException
- if there are any ERROR or DANGER events.IllegalStateException
- if there is no result.
-
validate
Get the optional result, and throw if there are any ERROR events.- Returns:
- Returns the optional result.
- Throws:
ValidatedResultException
- if there are any ERROR events.
-
isBroken
public boolean isBroken()Checks if the result has any error or danger events..- Returns:
- Returns true if there are errors or unsuppressed dangers.
-