Class ValueWrapper<T>

  • Type Parameters:
    T -

    public class ValueWrapper<T>
    extends java.lang.Object
    Utility class to wrap a value with the possibility to specify error message or propose valid value. - collectionPathToValue: In case of a failure with a collection value type, it holds the path to reach the wrong value Note: null can be used as value.
    • Method Detail

      • errorWithValidValue

        public static <T> ValueWrapper<T> errorWithValidValue​(T value,
                                                              T expected)
      • errorWithMessage

        public static <T> ValueWrapper<T> errorWithMessage​(java.lang.String message)
      • errorEmptyMessage

        public static <T> ValueWrapper<T> errorEmptyMessage()
      • errorWithCollectionPathToValue

        public static <T> ValueWrapper<T> errorWithCollectionPathToValue​(T value,
                                                                         java.util.List<java.lang.String> path)
      • isValid

        public boolean isValid()
      • getValue

        public T getValue()
      • getExpected

        public T getExpected()
      • getErrorMessage

        public java.util.Optional<java.lang.String> getErrorMessage()
      • getCollectionPathToValue

        public java.util.List<java.lang.String> getCollectionPathToValue()
      • orElse

        public T orElse​(T defaultValue)
      • orElseGet

        public T orElseGet​(java.util.function.Supplier<T> defaultSupplier)