Class EditResult<T>

java.lang.Object
tech.guilhermekaua.spigotboot.config.folder.EditResult<T>
Type Parameters:
T - the value type

public final class EditResult<T> extends Object
Result of an edit operation on a folder config.

Contains the success status, the resulting value (if any), and any validation errors that occurred.

  • Method Details

    • success

      public static <T> EditResult<T> success(@Nullable T value)
      Creates a successful result with a value.
      Type Parameters:
      T - the value type
      Parameters:
      value - the result value
      Returns:
      the success result
    • success

      public static <T> EditResult<T> success()
      Creates a successful result without a value.
      Type Parameters:
      T - the value type
      Returns:
      the success result
    • failure

      public static <T> EditResult<T> failure(@NotNull @NotNull String message)
      Creates a failure result with an error message.
      Type Parameters:
      T - the value type
      Parameters:
      message - the error message
      Returns:
      the failure result
    • validationFailure

      public static <T> EditResult<T> validationFailure(@NotNull @NotNull String message, @NotNull @NotNull List<String> validationErrors)
      Creates a failure result with validation errors.
      Type Parameters:
      T - the value type
      Parameters:
      message - the main error message
      validationErrors - the list of validation errors
      Returns:
      the failure result
    • isSuccess

      public boolean isSuccess()
      Returns true if the operation was successful.
      Returns:
      true if successful
    • isFailure

      public boolean isFailure()
      Returns true if the operation failed.
      Returns:
      true if failed
    • getValue

      @Nullable public T getValue()
      Gets the result value.
      Returns:
      the value, may be null even for successful operations
    • getOrThrow

      @NotNull public T getOrThrow()
      Gets the result value, throwing if the operation failed.
      Returns:
      the value
      Throws:
      IllegalStateException - if the operation failed
    • getErrorMessage

      @Nullable public @Nullable String getErrorMessage()
      Gets the error message if the operation failed.
      Returns:
      the error message, or null if successful
    • getValidationErrors

      @NotNull public @NotNull List<String> getValidationErrors()
      Gets the list of validation errors.
      Returns:
      the validation errors, empty if none
    • hasValidationErrors

      public boolean hasValidationErrors()
      Returns true if there are validation errors.
      Returns:
      true if there are validation errors
    • toString

      public String toString()
      Overrides:
      toString in class Object