Class BindingResult<T>
java.lang.Object
tech.guilhermekaua.spigotboot.config.binding.BindingResult<T>
- Type Parameters:
T- the type of the bound object
Result of a binding operation.
-
Method Summary
Modifier and TypeMethodDescription@NotNull List<BindingError>errors()Gets the binding errors.static <T> @NotNull BindingResult<T>failure(@NotNull List<BindingError> errors) Creates a result with binding errors.@NotNull StringFormats all errors for display.get()Gets the bound value.booleanChecks if there are any binding errors.booleanChecks if there are any validation errors.booleanChecks if binding was fully successful (no binding or validation errors).static <T> @NotNull BindingResult<T>of(T value, @NotNull List<BindingError> errors, @NotNull List<ValidationError> validationErrors) Creates a result with both binding and validation errors.Gets the value or a fallback.static <T> @NotNull BindingResult<T>success(T value) Creates a successful result.toString()@NotNull List<ValidationError>Gets the validation errors.static <T> @NotNull BindingResult<T>withValidationErrors(T value, @NotNull List<ValidationError> validationErrors) Creates a result with a value and validation errors.
-
Method Details
-
success
Creates a successful result.- Type Parameters:
T- the type- Parameters:
value- the bound value- Returns:
- a successful result
-
failure
@NotNull public static <T> @NotNull BindingResult<T> failure(@NotNull @NotNull List<BindingError> errors) Creates a result with binding errors.- Type Parameters:
T- the type- Parameters:
errors- the binding errors- Returns:
- a result with errors
-
withValidationErrors
@NotNull public static <T> @NotNull BindingResult<T> withValidationErrors(@NotNull T value, @NotNull @NotNull List<ValidationError> validationErrors) Creates a result with a value and validation errors.- Type Parameters:
T- the type- Parameters:
value- the bound valuevalidationErrors- the validation errors- Returns:
- a result with value and validation errors
-
of
@NotNull public static <T> @NotNull BindingResult<T> of(@Nullable T value, @NotNull @NotNull List<BindingError> errors, @NotNull @NotNull List<ValidationError> validationErrors) Creates a result with both binding and validation errors.- Type Parameters:
T- the type- Parameters:
value- the bound value (or null if binding failed)errors- the binding errorsvalidationErrors- the validation errors- Returns:
- a combined result
-
isSuccess
public boolean isSuccess()Checks if binding was fully successful (no binding or validation errors).- Returns:
- true if successful
-
hasErrors
public boolean hasErrors()Checks if there are any binding errors.- Returns:
- true if there are binding errors
-
hasValidationErrors
public boolean hasValidationErrors()Checks if there are any validation errors.- Returns:
- true if there are validation errors
-
get
Gets the bound value.- Returns:
- the value
- Throws:
ConfigException- if binding failed
-
orElse
Gets the value or a fallback.- Parameters:
fallback- the fallback value- Returns:
- the value or fallback
-
errors
Gets the binding errors.- Returns:
- the binding errors
-
validationErrors
Gets the validation errors.- Returns:
- the validation errors
-
formatErrors
Formats all errors for display.- Returns:
- the formatted errors
-
toString
-