Class MonitoredReturnProblem<T>

    • Method Detail

      • getValue

        @Nullable
        public T getValue​()
        Description copied from interface: RetVal
        Get the value contained in this instance. If this is an problem state, then the value will be null.

        This is usually helpful for log messages where a correctness check would impose extra runtime overhead that logging doesn't care about. This can also be used to return a simple value to other parts of a program that use null to indicate an invalid setup but that are separate from user notifications.

        Specified by:
        getValue in interface RetNullable<T>
        Specified by:
        getValue in interface RetVal<T>
        Specified by:
        getValue in interface ValuedProblemContainer<T>
        Returns:
        the value, which will be null if there are problems.
      • asOptional

        @Nonnull
        public java.util.Optional<T> asOptional​()
        Description copied from interface: RetVal
        Convert the value into an optional typed value. Note that doing this will lose any problem state, so checking for problems should be done before calling this.

        This function has limited use. It's provided here to allow support for systems that use Optional values.

        Specified by:
        asOptional in interface RetNullable<T>
        Specified by:
        asOptional in interface RetVal<T>
        Returns:
        the value as an optional type. No checks are made against the problem state.
      • result

        @Nonnull
        public T result​()
        Description copied from interface: RetVal
        Get the result, which is always non-null. If this instance has problems, then a runtime exception is thrown. Therefore, it's necessary to perform a validity check before calling.
        Specified by:
        result in interface RetNullable<T>
        Specified by:
        result in interface RetVal<T>
        Returns:
        the non-null value, only if this instance is ok.
      • requireOptional

        @Nonnull
        public java.util.Optional<T> requireOptional​()
        Description copied from interface: RetVal
        Convert the value into an optional typed value only if there are no problems.
        Specified by:
        requireOptional in interface RetNullable<T>
        Specified by:
        requireOptional in interface RetVal<T>
        Returns:
        the value as an optional type. No checks are made against the problem state.
      • forwardProblems

        @Nonnull
        public <V> MonitoredReturnProblem<V> forwardProblems​()
        Description copied from interface: RetVal
        Forward this object to a different typed RetVal instance. This will only work when the instance has problems.

        The most common use case is when a value construction requires multiple steps, and an early step requires early exit from the function. This allows a memory efficient type casting of the problems to the construction function's type.

        Specified by:
        forwardProblems in interface RetNullable<T>
        Specified by:
        forwardProblems in interface RetVal<T>
        Specified by:
        forwardProblems in interface RetVoid
        Type Parameters:
        V - altered type.
        Returns:
        the type-altered version
      • forwardNullableProblems

        @Nonnull
        public <V> RetNullable<V> forwardNullableProblems​()
        Description copied from interface: RetVal
        Forward this instance as a nullable with a different value type, but only if it has problems. If it does not have problems, then a runtime exception is thrown.

        The most common use case is when a value construction requires multiple steps, and an early step requires early exit from the function. This allows a memory efficient type casting of the problems to the construction function's type.

        Specified by:
        forwardNullableProblems in interface RetNullable<T>
        Specified by:
        forwardNullableProblems in interface RetVal<T>
        Specified by:
        forwardNullableProblems in interface RetVoid
        Type Parameters:
        V - destination type
        Returns:
        the value, only if this instance has problems.
      • forwardVoidProblems

        @Nonnull
        public RetVoid forwardVoidProblems​()
        Description copied from interface: RetVal
        Forward this instance as a value-less object, but only if it has problems. If it does not have problems, then a runtime exception is thrown.

        The most common use case is when a value construction requires multiple steps, and an early step requires early exit from the function. This allows a memory efficient type casting of the problems to the construction function's type.

        Specified by:
        forwardVoidProblems in interface RetNullable<T>
        Specified by:
        forwardVoidProblems in interface RetVal<T>
        Specified by:
        forwardVoidProblems in interface RetVoid
        Returns:
        the value, only if this instance has problems.
      • asNullable

        @Nonnull
        public RetNullable<T> asNullable​()
        Description copied from interface: RetVal
        Convert this instance into a nullable instance with the same value type. If this instance has problems, they are returned. This differs from RetVal.forwardNullableProblems() by 1. keeping the same type, and 2. allowing for a non-problem state in the returned value.

        A convenience function for situations where a receiver can expect valid uses of a null value when the source is known to never return a null value.

        Specified by:
        asNullable in interface RetVal<T>
        Returns:
        a nullable version of the same instance.
      • thenValidate

        @Nonnull
        public RetNullable<T> thenValidate​(@Nonnull
                                           java.util.function.Function<T,ProblemContainer> checker)
        Description copied from interface: RetNullable
        Validate the value in the checker. The checker can perform any amount of validation against the value as necessary, and returns an optional container of problems. If no problem is found, the checker can return null.

        Be careful with over-using this method. ValueBuilder and ProblemCollector provide better solutions for constructing validation problems within a method. This particular method finds practical use when a builder method returns an initially valid value, then another method performs cross-value validation.

        Specified by:
        thenValidate in interface RetNullable<T>
        Parameters:
        checker - function that checks the validity of the value.
        Returns:
        a retval with additional problems, or this value if no problem is found.
      • thenValidate

        @Nonnull
        public MonitoredReturnProblem<T> thenValidate​(@Nonnull
                                                      NonnullParamFunction<T,ProblemContainer> checker)
        Description copied from interface: RetVal
        Validate the value in the checker. The checker can perform any amount of validation against the value as necessary, and returns an optional container of problems. If no problem is found, the checker can return null. The checker is only invoked if the value has no current problems.

        Be careful with over-using this method. ValueBuilder and ProblemCollector provide better solutions for constructing validation problems within a method. This particular method finds practical use when a builder method returns an initially valid value, then another method performs cross-value validation.

        Specified by:
        thenValidate in interface RetVal<T>
        Parameters:
        checker - function that checks the validity of the value.
        Returns:
        a retval with additional problems, or this value if no problem is found.
      • thenNullable

        @Nonnull
        public <R> RetNullable<R> thenNullable​(@Nonnull
                                               NonnullFunction<T,RetNullable<R>> func)
        Description copied from interface: RetVal
        Return a non-null RetNullable value using a function that itself returns a RetNullable, taking the current non-null value as an argument. The function is called only if this object has no problem.

        This is similar to RetVal.mapNullable(NonnullParamFunction), but logically different. This method implies the functional argument will use the value and perform new processing to create a different value.

        Specified by:
        thenNullable in interface RetVal<T>
        Type Parameters:
        R - type of the returned value.
        Parameters:
        func - functional object that returns a RetNullable and takes the current value as argument.
        Returns:
        the problem of the current value, if it is a problem, or the object returned by the supplier.
      • thenNullable

        @Nonnull
        public <R> RetNullable<R> thenNullable​(@Nonnull
                                               NonnullSupplier<RetNullable<R>> supplier)
        Description copied from interface: RetVoid
        If there is no problem, run the supplier and return its value. Otherwise, return this object's problems.
        Specified by:
        thenNullable in interface RetVoid
        Type Parameters:
        R - return value type
        Parameters:
        supplier - supplier of the return value; run only if this object has no problems.
        Returns:
        the problems in this object, or the supplier's return value.
      • thenNullable

        @Nonnull
        public <R> RetNullable<R> thenNullable​(@Nonnull
                                               NonnullReturnFunction<T,RetNullable<R>> func)
        Description copied from interface: RetNullable
        Return a non-null RetNullable value using a function that itself returns a RetNullable, taking the current non-null value as an argument. The function is called only if this object has no problem.

        This is similar to RetNullable.mapNullable(Function), but logically different. This method implies the functional argument will use the value and perform new processing to create a different value.

        Specified by:
        thenNullable in interface RetNullable<T>
        Type Parameters:
        R - type of the returned value.
        Parameters:
        func - functional object that returns a RetNullable and takes the current value as argument.
        Returns:
        the problem of the current value, if it is a problem, or the object returned by the supplier.
      • thenRunNullable

        @Nonnull
        public RetNullable<T> thenRunNullable​(@Nonnull
                                              java.lang.Runnable runner)
        Description copied from interface: RetNullable
        Run the parameter, only if this instance has no problems.
        Specified by:
        thenRunNullable in interface RetNullable<T>
        Parameters:
        runner - the runnable to execute if no problems exist
        Returns:
        this instance
      • thenRunNullable

        @Nonnull
        public RetNullable<T> thenRunNullable​(@Nonnull
                                              java.util.function.Consumer<T> consumer)
        Description copied from interface: RetNullable
        Run the consumer with the current value, only if this instance has no problems.
        Specified by:
        thenRunNullable in interface RetNullable<T>
        Parameters:
        consumer - the consumer of this value to run if no problems exist
        Returns:
        this instance.
      • mapNullable

        @Nonnull
        public <R> RetNullable<R> mapNullable​(@Nonnull
                                              java.util.function.Supplier<R> supplier)
        Description copied from interface: RetVoid
        Return a non-null RetNullable value using a supplier that returns a value. The supplier is called only if this object has no problem.

        Formally, this doesn't "map" one value to another. However, for symmetry with the other Ret classes, it is here called map.

        Specified by:
        mapNullable in interface RetVoid
        Type Parameters:
        R - return value type
        Parameters:
        supplier - functional object that returns a non-null value.
        Returns:
        a RetVal, either a problem if this object has an problem, or the value returned by the supplier.
      • mapNullable

        @Nonnull
        public <R> RetNullable<R> mapNullable​(@Nonnull
                                              NonnullParamFunction<T,R> func)
        Description copied from interface: RetVal
        If this instance has no problems, then it runs the parameter with the current value. The returned value, which may be null, is wrapped in a nullable value. If this instance has problems, then the problem list is returned and the parameter is not run.

        This is similar to RetVal.thenNullable(NonnullFunction), but logically different. This method implies the functional argument performs a transformation of the data type into another one without validation checks.

        Specified by:
        mapNullable in interface RetVal<T>
        Type Parameters:
        R - return value type
        Parameters:
        func - the function to run.
        Returns:
        a transformed version of this object.
      • mapNullable

        @Nonnull
        public <R> RetNullable<R> mapNullable​(@Nonnull
                                              java.util.function.Function<T,R> func)
        Description copied from interface: RetNullable
        If this instance has no problems, then it runs the parameter with the current value. The returned value, which may be null, is wrapped in a nullable value. If this instance has problems, then the problem list is returned and the parameter is not run.

        This is similar to RetNullable.thenNullable(NonnullReturnFunction), but logically different. This method implies the functional argument performs a transformation of the data type into another one without validation checks.

        Specified by:
        mapNullable in interface RetNullable<T>
        Type Parameters:
        R - return value type
        Parameters:
        func - the function to run.
        Returns:
        a transformed version of this object.
      • then

        @Nonnull
        public <R> RetVal<R> then​(@Nonnull
                                  NonnullSupplier<RetVal<R>> supplier)
        Description copied from interface: RetVoid
        Return a non-null RetVal value using a supplier that itself returns a RetVal. The supplier is called only if this object has no problem.
        Specified by:
        then in interface RetVoid
        Type Parameters:
        R - type of the returned value.
        Parameters:
        supplier - functional object that returns a RetVal.
        Returns:
        the problem of the current value, if it is a problem, or the object returned by the supplier.
      • then

        @Nonnull
        public <R> RetVal<R> then​(@Nonnull
                                  NonnullFunction<T,RetVal<R>> func)
        Description copied from interface: RetVal
        Return a non-null RetVal value using a function that itself returns a RetVal, taking the current non-nullable value as an argument. The function is called only if this object has no problem. If it has a problem, then the current list of problems is returned as the new type.

        This is similar to RetVal.map(NonnullFunction), but logically different. This method implies the functional argument will use the value and perform new processing to create a different value.

        Specified by:
        then in interface RetVal<T>
        Type Parameters:
        R - type of the returned value.
        Parameters:
        func - functional object that returns a RetVal and takes the current value as argument.
        Returns:
        the problems of the current value, or the object returned by the function if there are no problems (but the returned value may have its own set of problems).
      • then

        @Nonnull
        public <R> RetVal<R> then​(@Nonnull
                                  NonnullReturnFunction<T,RetVal<R>> func)
        Description copied from interface: RetNullable
        Return a non-null RetVal value using a function that itself returns a RetVal, taking the current non-nullable value as an argument. The function is called only if this object has no problem. If it has a problem, then the current list of problems is returned as the new type.

        This is similar to RetNullable.map(NonnullReturnFunction), but logically different. This method implies the functional argument will use the value and perform new processing to create a different value.

        Specified by:
        then in interface RetNullable<T>
        Type Parameters:
        R - type of the returned value.
        Parameters:
        func - functional object that returns a RetVal and takes the current value as argument.
        Returns:
        the problems of the current value, or the object returned by the function if there are no problems (but the returned value may have its own set of problems).
      • map

        @Nonnull
        public <R> RetVal<R> map​(@Nonnull
                                 NonnullReturnFunction<T,R> func)
        Description copied from interface: RetNullable
        Return a non-null RetVal value, using a function that returns a non-null value, taking the current non-null value as an argument. The function is called only if this object has no problem. If it has a problem, then the current list of problems is returned as the new type.

        This is similar to RetNullable.then(NonnullReturnFunction), but logically different. This method implies the functional argument performs a transformation of the data type into another one without validation checks.

        Specified by:
        map in interface RetNullable<T>
        Type Parameters:
        R - type of the returned value.
        Parameters:
        func - functional object that takes the current value as argument, and returns a transformed value.
        Returns:
        the problem of the current value, if it is a problem, or the object returned by the function.
      • map

        @Nonnull
        public <R> RetVal<R> map​(@Nonnull
                                 NonnullFunction<T,R> func)
        Description copied from interface: RetVal
        Return a non-null RetVal value, using a function that returns a non-null value, taking the current non-null value as an argument. The function is called only if this object has no problem. If it has a problem, then the current list of problems is returned as the new type.

        This is similar to RetVal.then(NonnullFunction), but logically different. This method implies the functional argument performs a transformation of the data type into another one without validation checks.

        Specified by:
        map in interface RetVal<T>
        Type Parameters:
        R - type of the returned value.
        Parameters:
        func - functional object that takes the current value as argument, and returns a transformed value.
        Returns:
        the problem of the current value, if it is an problem, or the object returned by the function.
      • map

        @Nonnull
        public <R> RetVal<R> map​(@Nonnull
                                 NonnullSupplier<R> supplier)
        Description copied from interface: RetVoid
        Return a non-null RetVal value using a supplier that returns a value. The supplier is called only if this object has no problem.

        Formally, this doesn't "map" one value to another. However, for symmetry with the other Ret classes, it is here called map.

        Specified by:
        map in interface RetVoid
        Type Parameters:
        R - return value type
        Parameters:
        supplier - functional object that returns a non-null value.
        Returns:
        a RetVal, either a problem if this object has a problem, or the value returned by the supplier.
      • thenVoid

        @Nonnull
        public RetVoid thenVoid​(@Nonnull
                                NonnullSupplier<RetVoid> supplier)
        Description copied from interface: RetVoid
        Return the supplier if there is no problem.
        Specified by:
        thenVoid in interface RetVoid
        Parameters:
        supplier - function to run
        Returns:
        this object if there are problems in this object, otherwise the supplier's return value.
      • thenVoid

        @Nonnull
        public RetVoid thenVoid​(@Nonnull
                                NonnullConsumer<T> consumer)
        Description copied from interface: RetVal
        Pass the value of this instance to the consumer, only if there are no problems. Return a void version of this instance.

        A note about usage: if the argument is a lambda that ignores the argument, then the compiler will fail due to an ambiguous call. There exist some use cases where the argument value is no longer needed and can be safely ignored; for those scenarios, use RetVal.consume(NonnullConsumer).

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        thenVoid in interface RetVal<T>
        Parameters:
        consumer - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • thenVoid

        @Nonnull
        public RetVoid thenVoid​(@Nonnull
                                NonnullFunction<T,RetVoid> func)
        Description copied from interface: RetVal
        Pass the value of this instance to the function, only if there are no problems. Return a void version of this instance if there are problems with it, or the return value from the function.

        A note about usage: if the argument is a lambda that ignores the argument, then the compiler will fail due to an ambiguous call. There exist some use cases where the argument value is no longer needed and can be safely ignored; for those scenarios, use RetVal.produceVoid(NonnullFunction).

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        thenVoid in interface RetVal<T>
        Parameters:
        func - consumer of this value.
        Returns:
        the result of the function, if there are no problems, otherwise a RetVoid with this instance's problems.
      • thenVoid

        @Nonnull
        public RetVoid thenVoid​(@Nonnull
                                java.util.function.Consumer<T> consumer)
        Description copied from interface: RetNullable
        Pass the value of this instance to the consumer, only if there are no problems. Return a void version of this instance.

        A note about usage: if the argument is a lambda that ignores the argument, then the compiler will fail due to an ambiguous call. There exist some use cases where the argument value is no longer needed and can be safely ignored; for those scenarios, use RetNullable.consume(Consumer).

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        thenVoid in interface RetNullable<T>
        Parameters:
        consumer - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • thenVoid

        @Nonnull
        public RetVoid thenVoid​(@Nonnull
                                NonnullReturnFunction<T,RetVoid> func)
        Description copied from interface: RetNullable
        Pass the value of this instance to the consumer, only if there are no problems. Return the function's value.

        A note about usage: if the argument is a lambda that ignores the argument, then the compiler will fail due to an ambiguous call. There exist some use cases where the argument value is no longer needed and can be safely ignored; for those scenarios, use RetNullable.produceVoid(NonnullReturnFunction).

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        thenVoid in interface RetNullable<T>
        Parameters:
        func - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • consume

        @Nonnull
        public RetVoid consume​(@Nonnull
                               java.util.function.Consumer<T> consumer)
        Description copied from interface: RetNullable
        Pass the value of this instance to the consumer, only if there are no problems. Return a void version of this instance.

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        consume in interface RetNullable<T>
        Parameters:
        consumer - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • consume

        @Nonnull
        public RetVoid consume​(@Nonnull
                               NonnullConsumer<T> consumer)
        Description copied from interface: RetVal
        Pass the value of this instance to the consumer, only if there are no problems. Return a void version of this instance.

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        consume in interface RetVal<T>
        Parameters:
        consumer - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • produceVoid

        @Nonnull
        public RetVoid produceVoid​(@Nonnull
                                   NonnullReturnFunction<T,RetVoid> func)
        Description copied from interface: RetNullable
        Pass the value of this instance to the consumer, only if there are no problems. Return the function's value.

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        produceVoid in interface RetNullable<T>
        Parameters:
        func - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • produceVoid

        @Nonnull
        public RetVoid produceVoid​(@Nonnull
                                   NonnullFunction<T,RetVoid> func)
        Description copied from interface: RetVal
        Pass the value of this instance to the consumer, only if there are no problems. Return the function's value.

        This call will lose the contained value on return, so it's used to pass on the value to another object.

        Specified by:
        produceVoid in interface RetVal<T>
        Parameters:
        func - consumer of this value.
        Returns:
        a response that contains the problem state of the current value.
      • thenRun

        @Nonnull
        public MonitoredReturnProblem<T> thenRun​(@Nonnull
                                                 java.lang.Runnable runner)
        Description copied from interface: RetVal
        Run the parameter, only if this instance has no problems.
        Specified by:
        thenRun in interface RetVal<T>
        Specified by:
        thenRun in interface RetVoid
        Parameters:
        runner - the runnable to execute if no problems exist
        Returns:
        this instance
      • thenRun

        @Nonnull
        public MonitoredReturnProblem<T> thenRun​(@Nonnull
                                                 NonnullConsumer<T> consumer)
        Description copied from interface: RetVal
        Run the consumer with the current value, only if this instance has no problems.
        Specified by:
        thenRun in interface RetVal<T>
        Parameters:
        consumer - the consumer of this value to run if no problems exist
        Returns:
        this instance.
      • requireNonNull

        @Nonnull
        public RetVal<T> requireNonNull​(@Nonnull
                                        Problem problem,
                                        @Nonnull
                                        Problem... problems)
        Description copied from interface: RetNullable
        Require that this value contains a non-null value, otherwise produce a value with the problem arguments. If this value already has a problem, the arguments are ignored.
        Specified by:
        requireNonNull in interface RetNullable<T>
        Parameters:
        problem - problem to report if the value is null.
        problems - optional other problems to report if the value is null.
        Returns:
        if non-null, return this value, otherwise the problem arguments.
      • defaultAs

        @Nonnull
        public RetVal<T> defaultAs​(@Nonnull
                                   T defaultValue)
        Description copied from interface: RetNullable
        Returns this object as a RetVal if it is not null, otherwise a value with the returned value. If this value has a problem, that is still returned.
        Specified by:
        defaultAs in interface RetNullable<T>
        Parameters:
        defaultValue - value to use if this object contains a null value.
        Returns:
        the value with a non-null result, using the parameter if this object contains a null value.
      • consumeIfNonnull

        @Nonnull
        public RetVoid consumeIfNonnull​(@Nonnull
                                        NonnullConsumer<T> consumer)
        Description copied from interface: RetNullable
        If this value has a problem, then it is returned as a RetVoid. If it contains a null value, then the equivalent of RetVoid.ok() is returned. Otherwise, the consumer is called with the value, and RetVoid.ok() is returned.
        Specified by:
        consumeIfNonnull in interface RetNullable<T>
        Parameters:
        consumer - consumer called with the value if there are no problems and the value is non-null.
        Returns:
        the problems or a problem-free void value.
      • produceVoidIfNonnull

        @Nonnull
        public RetVoid produceVoidIfNonnull​(@Nonnull
                                            NonnullFunction<T,RetVoid> func)
        Description copied from interface: RetNullable
        If this value has a problem, then it is returned as a RetVoid. If it contains a null value, then the equivalent of RetVoid.ok() is returned. Otherwise, the consumer is called with the value, and RetVoid.ok() is returned.
        Specified by:
        produceVoidIfNonnull in interface RetNullable<T>
        Parameters:
        func - called with the value if there are no problems and the value is non-null, and the return value is returned by this call.
        Returns:
        the problems or a problem-free void value.
      • defaultOrMap

        @Nonnull
        public <R> RetVal<R> defaultOrMap​(@Nonnull
                                          R defaultValue,
                                          @Nonnull
                                          NonnullFunction<T,R> func)
        Description copied from interface: RetNullable
        If this value has a problem, then it is returned. If the stored value is null, then defaultValue is returned. If the stored value is non-null, then it is passed to the function and returned.
        Specified by:
        defaultOrMap in interface RetNullable<T>
        Type Parameters:
        R - mapped-to value type
        Parameters:
        defaultValue - value to return if the stored value is null.
        func - function to process the stored value if it is non-null.
        Returns:
        this value's problems, or the mapped-to value, or the default value.
      • nullOrMap

        @Nonnull
        public <R> RetNullable<R> nullOrMap​(@Nonnull
                                            NonnullParamFunction<T,R> func)
        Description copied from interface: RetNullable
        If this value has a problem, then it is returned. If the stored value is null, then null is returned. If the stored value is non-null, then it is passed to the function and returned.
        Specified by:
        nullOrMap in interface RetNullable<T>
        Type Parameters:
        R - mapped-to value type
        Parameters:
        func - function to process the stored value if it is non-null.
        Returns:
        this value's problems, or the mapped-to value, or the default value.
      • nullOrThenNullable

        @Nonnull
        public <R> RetNullable<R> nullOrThenNullable​(@Nonnull
                                                     NonnullFunction<T,RetNullable<R>> func)
        Description copied from interface: RetNullable
        If this value has a problem, then it is returned. If the stored value is null, then null is returned. If the stored value is non-null, then it is passed to the function and returned.
        Specified by:
        nullOrThenNullable in interface RetNullable<T>
        Type Parameters:
        R - mapped-to value type
        Parameters:
        func - function to process the stored value if it is non-null.
        Returns:
        this value's problems, or the mapped-to value, or the default value.
      • isProblem

        public boolean isProblem​()
        Description copied from interface: ProblemContainer
        Returns whether this object contains 1 or more problems.
        Specified by:
        isProblem in interface ProblemContainer
        Returns:
        true if there is a problem, false if there is no problem.
      • isOk

        public boolean isOk​()
        Description copied from interface: ProblemContainer
        Returns whether this object contains zero problems.
        Specified by:
        isOk in interface ProblemContainer
        Returns:
        true if there are no problems, false if there is a problem.
      • anyProblems

        @Nonnull
        public java.util.Collection<Problem> anyProblems​()
        Description copied from interface: ProblemContainer
        Return all the problems in this object, even if the container is "ok".

        Generally, this combines the problems in this instance with a larger collection, which can itself be used to check if any of the values had problems.

        The returned collection is read-only, and contains no null values.

        Specified by:
        anyProblems in interface ProblemContainer
        Returns:
        the problems contained in this container, even if there are none.
      • validProblems

        @Nonnull
        public java.util.Collection<Problem> validProblems​()
        Description copied from interface: ProblemContainer
        Returns all contained problems in this object, but only if this object contains 1 or more problems. If it contains 0, then this throws an IllegalStateException.

        The returned collection is read-only, and contains no null values.

        Specified by:
        validProblems in interface ProblemContainer
        Returns:
        the problems in this container, and the collection will contain at least 1 item.
      • debugProblems

        @Nonnull
        public java.lang.String debugProblems​(@Nonnull
                                              java.lang.String joinedWith)
        Description copied from interface: ProblemContainer
        Return the problems as a single string, which combines the Object.toString() output of each problem with the given joining string parameter. If this object contains no problems, then an empty string is returned instead.
        Specified by:
        debugProblems in interface ProblemContainer
        Parameters:
        joinedWith - the text to join multiple problem strings together.
        Returns:
        the combined text of the problems, or an empty string if there are no problems.
      • joinProblemsWith

        public void joinProblemsWith​(@Nonnull
                                     java.util.Collection<Problem> problemList)
        Description copied from interface: ProblemContainer
        Add all problems in this container into the argument. This has a very specific usage to indicate that this container, even if it has no problems, is part of a bigger issue. Therefore, this is fine to call even if there are no problems in this container.
        Specified by:
        joinProblemsWith in interface ProblemContainer
        Parameters:
        problemList - a modifiable collection of zero or more problems.
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object