Class ValueOrException<V,​E extends java.lang.Throwable & SensibleClone<E>>


  • public class ValueOrException<V,​E extends java.lang.Throwable & SensibleClone<E>>
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ValueOrException​(V value, E exception, boolean useValue)
      dual-purpose private constructor: one will be null, and the flag tells which to use
    • Field Detail

      • _useValue

        private final boolean _useValue
      • _value

        private final V _value
      • _exception

        private final E extends java.lang.Throwable & SensibleClone<E> _exception
    • Constructor Detail

      • ValueOrException

        private ValueOrException​(V value,
                                 E exception,
                                 boolean useValue)
        dual-purpose private constructor: one will be null, and the flag tells which to use
        Parameters:
        value - the value to wrap, if applicable
        exception - the exception to wrap, if applicable
        useValue - true if we should use the value, rather than the exception
    • Method Detail

      • makeValue

        public static <V,​E extends java.lang.Throwable & SensibleClone<E>> ValueOrException<V,​E> makeValue​(V value)
        Factory method for values
        Parameters:
        value - the value to wrap as a ValueOrException
        Returns:
        the wrapped value
      • makeException

        public static <V,​E extends java.lang.Throwable & SensibleClone<E>> ValueOrException<V,​E> makeException​(E exception)
        Factory method for exceptions
        Parameters:
        exception - the exception to wrap as a ValueOrException
        Returns:
        the wrapped exception
      • getValue

        public V getValue()
                   throws E extends java.lang.Throwable & SensibleClone<E>
        Retrieve value or throw exception
        Returns:
        the wrapped value, if it's a value
        Throws:
        E - the wrapped exception, if it's an exception
        E extends java.lang.Throwable & SensibleClone<E>