Class BindingResult<T>

java.lang.Object
tech.guilhermekaua.spigotboot.config.binding.BindingResult<T>
Type Parameters:
T - the type of the bound object

public final class BindingResult<T> extends Object
Result of a binding operation.
  • Method Details

    • success

      @NotNull public static <T> @NotNull BindingResult<T> success(@NotNull T value)
      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 value
      validationErrors - 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 errors
      validationErrors - 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

      @NotNull public T get() throws ConfigException
      Gets the bound value.
      Returns:
      the value
      Throws:
      ConfigException - if binding failed
    • orElse

      @Nullable public T orElse(@Nullable T fallback)
      Gets the value or a fallback.
      Parameters:
      fallback - the fallback value
      Returns:
      the value or fallback
    • errors

      @NotNull public @NotNull List<BindingError> errors()
      Gets the binding errors.
      Returns:
      the binding errors
    • validationErrors

      @NotNull public @NotNull List<ValidationError> validationErrors()
      Gets the validation errors.
      Returns:
      the validation errors
    • formatErrors

      @NotNull public @NotNull String formatErrors()
      Formats all errors for display.
      Returns:
      the formatted errors
    • toString

      public String toString()
      Overrides:
      toString in class Object