Klasse Error<None>

java.lang.Object
de.srsoftware.tools.container.Error<None>
Typparameter:
None - This result is not expected to carry a payload in the sense of a positive execution result.
Alle implementierten Schnittstellen:
Container<None>

public class Error<None> extends Object implements Container<None>
This class may be returned by methods whose execution failed. It may carry additional data about the cause of the failure
  • Felddetails

  • Konstruktordetails

    • Error

      public Error(String message, Map<String,Object> data, Collection<Exception> exceptions)
      create a new Error object carrying the passed message
      Parameter:
      message - the message to add to the Error object
      data - (optional) data to carry along
      exceptions - (optional) exceptions to wrap
  • Methodendetails

    • add

      public Error<None> add(Exception exception)
      add an exception to this Error object
      Parameter:
      exception - the exception to add
      Gibt zurück:
      this object
    • addData

      public Error<None> addData(Object... tokens)
      Add values to the data map
      Parameter:
      tokens - a list of objects. The even elements are used as key in the data map, the odd ones as values.
      Gibt zurück:
      this Error object
    • data

      public Map<String,Object> data()
      return the data map
      Gibt zurück:
      metadata added to this Error object
    • error

      public static <T> Error<T> error(String message, Object... fills)
      create a new Error object carrying the passed message
      Typparameter:
      T - the type of the result expected at the place this error occurred
      Parameter:
      message - the message to add to the Error object, may contain placeholder marks
      fills - the list of objects to fill the marks
      Gibt zurück:
      the created Error object
    • error

      public static <T> Error<T> error(Exception exception, String message, Object... fills)
      create a new Error object carrying the passed message
      Typparameter:
      T - the type of the result expected at the place this error occurred
      Parameter:
      exception - exception to wrap
      message - the message to add to the Error object, may contain placeholder marks
      fills - the list of objects to fill the marks
      Gibt zurück:
      the created Error object
    • error

      public static <T> Error<T> error(Collection<Exception> exceptions, String message, Object... fills)
      create a new Error object carrying the passed message
      Typparameter:
      T - the type of the result expected at the place this error occurred
      Parameter:
      exceptions - (optional) exceptions to wrap
      message - the message to add to the Error object, may contain placeholder marks
      fills - the list of objects to fill the marks
      Gibt zurück:
      the created Error object
    • error

      public static <T> Error<T> error(Map<String,Object> data, String message, Object... fills)
      create a new Error object carrying the passed message
      Typparameter:
      T - the type of the result expected at the place this error occurred
      Parameter:
      data - (optional) data to carry along
      message - the message to add to the Error object, may contain placeholder marks
      fills - the list of objects to fill the marks
      Gibt zurück:
      the created Error object
    • error

      public static <T> Error<T> error(Map<String,Object> data, Exception exception, String message, Object... fills)
      create a new Error object carrying the passed message
      Typparameter:
      T - the type of the result expected at the place this error occurred
      Parameter:
      data - (optional) data to carry along
      exception - exceptions to wrap
      message - the message to add to the Error object, may contain placeholder marks
      fills - the list of objects to fill the marks
      Gibt zurück:
      the created Error object
    • error

      public static <T> Error<T> error(Map<String,Object> data, Collection<Exception> exceptions, String message, Object... fills)
      create a new Error object carrying the passed message
      Typparameter:
      T - the type of the result expected at the place this error occurred
      Parameter:
      data - (optional) data to carry along
      exceptions - (optional) exceptions to wrap
      message - the message to add to the Error object, may contain placeholder marks
      fills - the list of objects to fill the marks
      Gibt zurück:
      the created Error object
    • exceptions

      public Collection<Exception> exceptions()
      get the collection of Exceptions added to this Error object
      Gibt zurück:
      the list of Exceptions
    • isEmpty

      public boolean isEmpty()
      Beschreibung aus Schnittstelle kopiert: Container
      checks whether the object returned by optional() is empty
      Angegeben von:
      isEmpty in Schnittstelle Container<None>
      Gibt zurück:
      true, only if optional().isEmpty() returns true
    • json

      public org.json.JSONObject json()
      Create a json object of the error.
      Gibt zurück:
      the json object describing the error.
    • message

      public String message()
      return the message encapsulated in this error object
      Gibt zurück:
      the message string
    • optional

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

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

      public <Inner> Stream<Container<Inner>> streamContained()
      Beschreibung aus Schnittstelle kopiert: Container
      Create a stream of the Payload. This may be suitable, if the payload is a collection.
      Angegeben von:
      streamContained in Schnittstelle Container<None>
      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
    • then

      public <T> T then(Function<Error<None>,T> mapper)
      map an error to another object
      Typparameter:
      T - type of the expected result
      Parameter:
      mapper - the mapper function
      Gibt zurück:
      the object returned by the mapper function
    • transform

      public <NewType> Error<NewType> transform()
      create an Error with the same metadata content as this Object, but with different payload type
      Typparameter:
      NewType - the payload type of the returned error
      Gibt zurück:
      the transformed Error (new object)
    • wrap

      public Optional<Error<None>> wrap()
      Wrap an error object as Optional
      Gibt zurück:
      an Optional carrying this Error object