Schnittstelle Container<Content>

Typparameter:
Content - The expected type of the result payload
Alle bekannten Implementierungsklassen:
Error, 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 Typ
    Methode
    Beschreibung
    default boolean
    checks whether the object returned by optional() is empty
    default <T> T
    Transform this Result object to another via a mapping function.
    Create an Optional from a Result.
    <Inner> Stream<Inner>
    Create a stream of the Payload.
    <Inner> Stream<Container<Inner>>
    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

      default <T> T map(Function<Container<Content>,T> mapper)
      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

      Optional<Content> optional()
      Create an Optional from a Result.
      Gibt zurück:
      An optional containing the Result`s content, if set.
    • streamContained

      <Inner> Stream<Container<Inner>> 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

      <Inner> Stream<Inner> 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

      static <T> Error<T> transform(Container<?> res)
      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