Class AbstractResult<DATA>

java.lang.Object
org.fuin.cqrs4j.AbstractResult<DATA>
Type Parameters:
DATA - Type of data returned.
All Implemented Interfaces:
Serializable, Result<DATA>
Direct Known Subclasses:
DataResult, SimpleResult

public abstract class AbstractResult<DATA> extends Object implements Result<DATA>, Serializable
Result of a request. The type signals if the execution was successful or not. In case the the result is not ResultType.OK, the fields code and message should contain unique information to help the user identifying the cause of the problem. A result may carry some optional data.
See Also:
  • Constructor Details

    • AbstractResult

      protected AbstractResult()
      Protected default constructor for de-serialization.
    • AbstractResult

      public AbstractResult(@NotNull @NotNull ResultType type, @Nullable String code, @Nullable String message)
      Constructor with all data.
      Parameters:
      type - Type.
      code - Code.
      message - Message.
    • AbstractResult

      public AbstractResult(@NotNull @NotNull Exception exception)
      Constructor with exception. An exception of type ExceptionShortIdentifable will be used to fill the code field with the identifier value. If it's not a ExceptionShortIdentifable the code field will be set using the full qualified class name of the exception.
      Parameters:
      exception - The message for the result is equal to the exception message or the simple name of the exception class if the exception message is null.
  • Method Details

    • getType

      public final ResultType getType()
      Description copied from interface: Result
      Returns the result type.
      Specified by:
      getType in interface Result<DATA>
      Returns:
      Type.
    • getCode

      public final String getCode()
      Description copied from interface: Result
      Returns the result code.
      Specified by:
      getCode in interface Result<DATA>
      Returns:
      Code.
    • getMessage

      public final String getMessage()
      Description copied from interface: Result
      Returns the result message.
      Specified by:
      getMessage in interface Result<DATA>
      Returns:
      Message.