Package de.srsoftware.tools.container
Schnittstelle Container<Content>
- Typparameter:
Content- The expected type of the result payload
public interface Container<Content>
This interface can be used as a result type for functions that may return something or an error.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungdefault booleanisEmpty()checks whether the object returned by optional() is emptydefault <T> TTransform this Result object to another via a mapping function.optional()Create an Optional from a Result.<Inner> Stream<Inner> stream()Create a stream of the Payload.Create a stream of the Payload.static <T> Error<T> Transforms the Result to an Error with appropriate payload type
-
Methodendetails
-
isEmpty
default boolean isEmpty()checks whether the object returned by optional() is empty- Gibt zurück:
- true, only if optional().isEmpty() returns true
-
map
Transform this Result object to another via a mapping function.- Typparameter:
T- the result type of the mapping function- Parameter:
mapper- a function, that processes results and produces results- Gibt zurück:
- the result of the mapping function
-
optional
Create an Optional from a Result.- Gibt zurück:
- An optional containing the Result`s content, if set.
-
streamContained
Create a stream of the Payload. This may be suitable, if the payload is a collection.- Typparameter:
Inner- the type of the payloads of the elements of the stream- Gibt zurück:
- a stream of results
-
stream
Create a stream of the Payload. This may be suitable, if the payload is a collection.- Typparameter:
Inner- the type of the elements of the stream- Gibt zurück:
- a stream of the contents items.
-
transform
Transforms the Result to an Error with appropriate payload type- Typparameter:
T- the payload type of the returned error- Parameter:
res- if this result is an error, it will be transformed using the Error.transform method, otherwise a new Error will be created- Gibt zurück:
- the transformed error
-