Class RetGenerator



  • public class RetGenerator
    extends java.lang.Object
    Central handler for creating Ret* instances.
    • Method Detail

      • nullableOk

        @Nonnull
        public static <T> RetNullable<T> nullableOk​(@Nullable
                                                    T value)
        Create a RetNullable instance with a value.
        Type Parameters:
        T - type of the value.
        Parameters:
        value - value to store in the return object.
        Returns:
        the return object.
      • nullableFromProblem

        @Nonnull
        public static <T> RetNullable<T> nullableFromProblem​(@Nonnull
                                                             java.util.Collection<Problem> problems)
        Create a RetNullable instance with one or more problems.
        Type Parameters:
        T - type of the value.
        Parameters:
        problems - collection of problem values.
        Returns:
        the return object.
      • valOk

        @Nonnull
        public static <T> RetVal<T> valOk​(@Nonnull
                                          T value)
        Create a new RetVal instance that has a value and no problems.
        Type Parameters:
        T - type of the value.
        Parameters:
        value - non-null value.
        Returns:
        a RetVal containing the value.
        Throws:
        java.lang.NullPointerException - if the value is null.
      • valFromProblem

        @Nonnull
        public static <T> RetVal<T> valFromProblem​(@Nonnull
                                                   java.util.Collection<Problem> problems)
        Create a new RetVal instance that has errors.
        Type Parameters:
        T - type of the value
        Parameters:
        problems - list of other problems to include in this value.
        Returns:
        an error RetVal.
      • voidOk

        @Nonnull
        public static RetVoid voidOk​()
        Return a void object with no problems.
        Returns:
        a no-problem void object.
      • voidFromProblem

        @Nonnull
        public static RetVoid voidFromProblem​(@Nonnull
                                              java.util.Collection<Problem> problems)
        Constructs a RetVoid instance with the collections of problems. This is optimized to reduce the memory load where easy. If the problem list is empty, then
        Parameters:
        problems - collection of problems
        Returns:
        a problem version of a void ret.
      • getFactory

        @Nonnull
        public static ReturnTypeFactory getFactory​()
        Allows for querying the active return type factory. Primarily useful for unit tests or other systems that need runtime replacements of the type.
        Returns:
        the current return type factory instance.
      • setFactory

        public static void setFactory​(@Nonnull
                                      ReturnTypeFactory factory)
        Allows for replacing the active return type factory. Primarily useful for unit tests or other systems that need runtime replacements of the type.
        Parameters:
        factory - the new factory to use; must be non-null.