Package org.danilopianini.jirf
Class ImmutableCreationResult<T>
- java.lang.Object
-
- org.danilopianini.jirf.ImmutableCreationResult<T>
-
- Type Parameters:
T
- the created object type
- All Implemented Interfaces:
CreationResult<T>
public final class ImmutableCreationResult<T> extends java.lang.Object implements CreationResult<T>
Immutable implementation ofCreationResult
(of course, if T is mutable, the object state can be indirectly mutated).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableCreationResult.Builder<T>
Builder for anImmutableCreationResult
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.util.Optional<T>
getCreatedObject()
T
getCreatedObjectOrThrowException()
com.google.common.collect.ImmutableMap<java.lang.reflect.Constructor<T>,InstancingImpossibleException>
getExceptions()
int
hashCode()
java.lang.String
toString()
-
-
-
Method Detail
-
getCreatedObject
public java.util.Optional<T> getCreatedObject()
- Specified by:
getCreatedObject
in interfaceCreationResult<T>
- Returns:
- an
Optional
wrapping the object built by the factory, or an empty optional if none was produced
-
getCreatedObjectOrThrowException
public T getCreatedObjectOrThrowException()
- Specified by:
getCreatedObjectOrThrowException
in interfaceCreationResult<T>
- Returns:
- the object built by the factory. If none was built, an exception is thrown.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getExceptions
public com.google.common.collect.ImmutableMap<java.lang.reflect.Constructor<T>,InstancingImpossibleException> getExceptions()
- Specified by:
getExceptions
in interfaceCreationResult<T>
- Returns:
- a
Map
containing, for each constructor that failed, the failure cause. The iteration order of this map is guaranteed to return itsMap.Entry
in the order they were produced (from the most suitable constructor to the last).
-
-