Class 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 of CreationResult (of course, if T is mutable, the object state can be indirectly mutated).
    • Method Detail

      • getCreatedObject

        public java.util.Optional<T> getCreatedObject()
        Specified by:
        getCreatedObject in interface CreationResult<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 interface CreationResult<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 class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getExceptions

        public com.google.common.collect.ImmutableMap<java.lang.reflect.Constructor<T>,​InstancingImpossibleException> getExceptions()
        Specified by:
        getExceptions in interface CreationResult<T>
        Returns:
        a Map containing, for each constructor that failed, the failure cause. The iteration order of this map is guaranteed to return its Map.Entry in the order they were produced (from the most suitable constructor to the last).