Class EditResult<T>
java.lang.Object
tech.guilhermekaua.spigotboot.config.folder.EditResult<T>
- Type Parameters:
T- the value type
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 Summary
Modifier and TypeMethodDescriptionstatic <T> EditResult<T>Creates a failure result with an error message.@Nullable StringGets the error message if the operation failed.Gets the result value, throwing if the operation failed.Gets the list of validation errors.getValue()Gets the result value.booleanReturns true if there are validation errors.booleanReturns true if the operation failed.booleanReturns true if the operation was successful.static <T> EditResult<T>success()Creates a successful result without a value.static <T> EditResult<T>success(T value) Creates a successful result with a value.toString()static <T> EditResult<T>validationFailure(@NotNull String message, @NotNull List<String> validationErrors) Creates a failure result with validation errors.
-
Method Details
-
success
Creates a successful result with a value.- Type Parameters:
T- the value type- Parameters:
value- the result value- Returns:
- the success result
-
success
Creates a successful result without a value.- Type Parameters:
T- the value type- Returns:
- the success result
-
failure
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 messagevalidationErrors- 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
Gets the result value.- Returns:
- the value, may be null even for successful operations
-
getOrThrow
Gets the result value, throwing if the operation failed.- Returns:
- the value
- Throws:
IllegalStateException- if the operation failed
-
getErrorMessage
Gets the error message if the operation failed.- Returns:
- the error message, or null if successful
-
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
-