Class ArgumentParseResult<T>
java.lang.Object
cloud.commandframework.arguments.parser.ArgumentParseResult<T>
- Type Parameters:
T
- Parser return type
Result of the parsing done by a
ArgumentParser
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NonNull ArgumentParseResult<T>
Indicate that the parsing failedabstract <U> @NonNull ArgumentParseResult<U>
flatMapParsedValue(Function<T,ArgumentParseResult<U>> mapper)
If this result is successful, transform the output value, returning another parse result.Get the failure reason, if it existsGet the parsed value, if it existsabstract @NonNull ArgumentParseResult<T>
mapFailure(Function<Throwable,Throwable> mapper)
If this result is a failure, transform the exception.abstract <U> @NonNull ArgumentParseResult<U>
mapParsedValue(Function<T,U> mapper)
If this result is successful, transform the output value.static <T> @NonNull ArgumentParseResult<T>
success(@NonNull T value)
Indicate that the parsing succeeded
-
Method Details
-
failure
Indicate that the parsing failed- Type Parameters:
T
- Parser return type- Parameters:
failure
- Failure reason- Returns:
- Failed parse result
-
success
Indicate that the parsing succeeded- Type Parameters:
T
- Parser return type- Parameters:
value
- Value produced by the parser- Returns:
- Succeeded parse result
-
getParsedValue
Get the parsed value, if it exists- Returns:
- Optional containing the parsed value
-
mapParsedValue
If this result is successful, transform the output value.- Type Parameters:
U
- the result type- Parameters:
mapper
- the transformation- Returns:
- a new result if successful, otherwise a failure
- Since:
- 1.5.0
-
flatMapParsedValue
public abstract <U> @NonNull ArgumentParseResult<U> flatMapParsedValue(Function<T,ArgumentParseResult<U>> mapper)If this result is successful, transform the output value, returning another parse result.- Type Parameters:
U
- the result type- Parameters:
mapper
- the transformation- Returns:
- a new result if successful, otherwise a failure
- Since:
- 1.5.0
-
getFailure
Get the failure reason, if it exists- Returns:
- Optional containing the failure reason
-
mapFailure
If this result is a failure, transform the exception.- Parameters:
mapper
- the exception transformation- Returns:
- if this is a failure, a transformed result, otherwise this
- Since:
- 1.5.0
-