Package jjparse
Class Parsing.Success<T>
- Type Parameters:
T- The covariant type of the parsed value.
Represents a successful result of a parsing operation.
Note: This class is intended to be immutable and hence covariant in its type parameter.
Note: This class is intended to be immutable and hence covariant in its type parameter.
- Author:
- Björn Lötters
- See Also:
-
Field Summary
FieldsFields inherited from class jjparse.Parsing.Result
rest -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMaps the value of thisParsing.Resultin case it is aParsing.Successto anotherParsing.Resultusing the providedFunctionand flattens the nestedParsing.Result.get()Returns the value of thisParsing.Result, if it is present.Returns the value of thisParsing.Resultor fails with an exception, if it is not present.booleanChecks whether thisParsing.Resultis aParsing.Failure.booleanChecks whether thisParsing.Resultis aParsing.Success.
-
Field Details
-
value
The parsed value of thisParsing.Success.
-
-
Constructor Details
-
Success
Constructs a newParsing.Success.- Parameters:
value- The parsed value.rest- The rest of theInput.
-
-
Method Details
-
get
Description copied from class:Parsing.ResultReturns the value of thisParsing.Result, if it is present. -
getOrFail
Description copied from class:Parsing.ResultReturns the value of thisParsing.Resultor fails with an exception, if it is not present.- Specified by:
getOrFailin classParsing<I>.Result<T>- Returns:
- The value of this
Parsing.Result. - Throws:
NoSuchElementException- If thisParsing.Resultis not aParsing.Success.
-
isFailure
public boolean isFailure()Description copied from class:Parsing.ResultChecks whether thisParsing.Resultis aParsing.Failure.- Specified by:
isFailurein classParsing<I>.Result<T>- Returns:
trueif thisParsing.Resultis aParsing.Failure.
-
isSuccess
public boolean isSuccess()Description copied from class:Parsing.ResultChecks whether thisParsing.Resultis aParsing.Success.- Specified by:
isSuccessin classParsing<I>.Result<T>- Returns:
trueif thisParsing.Resultis aParsing.Success.
-
map
Description copied from class:Parsing.Result -
flatMap
Description copied from class:Parsing.ResultMaps the value of thisParsing.Resultin case it is aParsing.Successto anotherParsing.Resultusing the providedFunctionand flattens the nestedParsing.Result.- Specified by:
flatMapin classParsing<I>.Result<T>- Type Parameters:
U- The type of the returnedParsing.Result.- Parameters:
function- TheFunctionused to map the value.- Returns:
- The
Parsing.Resultof the mapped value.
-