Klasse Payload<P>

java.lang.Object
de.srsoftware.tools.Payload<P>
Typparameter:
P - the type of the expected payload
Alle implementierten Schnittstellen:
Result<P>

public class Payload<P> extends Object implements Result<P>
A wrapper for results that carry an actual payload
  • Konstruktordetails

    • Payload

      public Payload(P object)
      Wrap a payload as a successful instance of Result
      Parameter:
      object - the payload object
  • Methodendetails

    • of

      public static <P> Payload<P> of(P object)
      wrap a payload
      Typparameter:
      P - the type of the payload
      Parameter:
      object - the payload to pack
      Gibt zurück:
      the wrapped payload object
    • get

      public P get()
      get the payload
      Gibt zurück:
      the payload object
    • map

      public <Mapped> Result<Mapped> map(Function<Result<P>,Result<Mapped>> mapper)
      Beschreibung aus Schnittstelle kopiert: Result
      Transform this Result object to another via a mapping function.
      Angegeben von:
      map in Schnittstelle Result<P>
      Typparameter:
      Mapped - the payload type of the result of the mapping function
      Parameter:
      mapper - a function, that processes results and produces results
      Gibt zurück:
      the result of the mapping function
    • optional

      public Optional<P> optional()
      Beschreibung aus Schnittstelle kopiert: Result
      Create an Optional from a Result.
      Angegeben von:
      optional in Schnittstelle Result<P>
      Gibt zurück:
      An optional containing the Result`s content, if set.
    • stream

      public <Inner> Stream<Result<Inner>> stream()
      Beschreibung aus Schnittstelle kopiert: Result
      Create a stream of the Payload. This may be suitable, if the payload is a collection.
      Angegeben von:
      stream in Schnittstelle Result<P>
      Typparameter:
      Inner - the type of the payloads of the elements of the stream
      Gibt zurück:
      a stream of results
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object