Class SimpleResult

All Implemented Interfaces:
Serializable, Result<Void>

public final class SimpleResult extends AbstractResult<Void>
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 simple result does not carry any additional data.
See Also:
  • Constructor Details

    • SimpleResult

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

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

      public SimpleResult(@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

    • getData

      public Void getData()
      Description copied from interface: Result
      Returns the result data.
      Returns:
      Optional data.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • ok

      public static SimpleResult ok()
      Create a success result.
      Returns:
      Result with type ResultType.OK.
    • warning

      public static SimpleResult warning(@NotNull @NotNull String code, @NotNull @NotNull String message)
      Create a warning result.
      Parameters:
      code - Code.
      message - Message.
      Returns:
      Result with type ResultType.WARNING.
    • error

      public static SimpleResult error(@NotNull @NotNull String code, @NotNull @NotNull String message)
      Create an error result.
      Parameters:
      code - Code.
      message - Message.
      Returns:
      Result with type ResultType.ERROR.