Package net.groboclown.retval.impl
Class SimpleFactory
- java.lang.Object
-
- net.groboclown.retval.impl.SimpleFactory
-
- All Implemented Interfaces:
ReturnTypeFactory
public class SimpleFactory extends java.lang.Object implements ReturnTypeFactory
Generates unmonitored, streamlined implementations.
-
-
Field Summary
Fields Modifier and Type Field Description static SimpleFactoryINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> RetNullable<T>createNullableFromProblems(java.util.List<Problem> problems)Create aRetNullableinstance with one or more problems.<T> RetNullable<T>createNullableOk(T value)Create aRetNullableinstance with a value.<T> RetVal<T>createValFromProblems(java.util.List<Problem> problems)Create a new RetVal instance that has errors.<T> RetVal<T>createValOk(T value)Create a new RetVal instance that has a value and no problems.RetVoidcreateVoidFromProblems(java.util.List<Problem> problems)Constructs aRetVoidinstance with the collections of problems.RetVoidcreateVoidOk()Return a void object with no problems.
-
-
-
Field Detail
-
INSTANCE
public static final SimpleFactory INSTANCE
-
-
Method Detail
-
createNullableOk
@Nonnull public <T> RetNullable<T> createNullableOk(@Nullable T value)
Description copied from interface:ReturnTypeFactoryCreate aRetNullableinstance with a value.- Specified by:
createNullableOkin interfaceReturnTypeFactory- Type Parameters:
T- type of the value.- Parameters:
value- value to store in the return object.- Returns:
- the return object.
-
createNullableFromProblems
@Nonnull public <T> RetNullable<T> createNullableFromProblems(@Nonnull java.util.List<Problem> problems)
Description copied from interface:ReturnTypeFactoryCreate aRetNullableinstance with one or more problems. The problems are checked before calling to have at least 1 value, no values are null, and the collection is unmodifiable.- Specified by:
createNullableFromProblemsin interfaceReturnTypeFactory- Type Parameters:
T- type of the value.- Parameters:
problems- collection of 1 or more problem values.- Returns:
- the return object.
-
createValOk
@Nonnull public <T> RetVal<T> createValOk(@Nonnull T value)
Description copied from interface:ReturnTypeFactoryCreate a new RetVal instance that has a value and no problems. The passed-in value is checked before calling to ensure it is non-null.- Specified by:
createValOkin interfaceReturnTypeFactory- Type Parameters:
T- type of the value.- Parameters:
value- non-null value; guaranteed to be non-null.- Returns:
- a RetVal containing the value.
-
createValFromProblems
@Nonnull public <T> RetVal<T> createValFromProblems(@Nonnull java.util.List<Problem> problems)
Description copied from interface:ReturnTypeFactoryCreate a new RetVal instance that has errors. The problems are checked before calling to have at least 1 value, no values are null, and the collection is unmodifiable.- Specified by:
createValFromProblemsin interfaceReturnTypeFactory- Type Parameters:
T- type of the value- Parameters:
problems- list of other problems to include in this value; guaranteed to have at least 1 value.- Returns:
- an error RetVal.
-
createVoidOk
@Nonnull public RetVoid createVoidOk()
Description copied from interface:ReturnTypeFactoryReturn a void object with no problems.- Specified by:
createVoidOkin interfaceReturnTypeFactory- Returns:
- a no-problem void object.
-
createVoidFromProblems
@Nonnull public RetVoid createVoidFromProblems(@Nonnull java.util.List<Problem> problems)
Description copied from interface:ReturnTypeFactoryConstructs aRetVoidinstance with the collections of problems. The list of problems is guaranteed by the caller to have at least 1 problem, no values are null, and the collection is unmodifiable.- Specified by:
createVoidFromProblemsin interfaceReturnTypeFactory- Parameters:
problems- list of problems that should be included in this object.- Returns:
- a RetVoid with all the given problems.
-
-