Class ResolutionResult<V>

  • Type Parameters:
    V - the result type

    public final class ResolutionResult<V>
    extends java.lang.Object
    A container for the result of a resolution operation.

    This indicates both whether a value was resolved, as well as whether that resolution was an up-to-date response, or required information to be re-processed.

    • Method Detail

      • result

        public static <T> ResolutionResult<T> result​(T result,
                                                     boolean upToDate)
      • get

        public V get()
        Assert that this resolution has a result.
        Returns:
        the result
        Throws:
        java.util.NoSuchElementException - if no value was present
      • orElseNull

        public @Nullable V orElseNull()
        Get a result from this resolution action, if present.
        Returns:
        the result
      • orElseThrow

        public <E extends java.lang.Exception> V orElseThrow​(java.util.function.Supplier<E> exceptionSupplier)
                                                      throws E extends java.lang.Exception
        Get a present value from this result, or throw the provided exception.
        Type Parameters:
        E - the type of exception to throw
        Parameters:
        exceptionSupplier - a supplier providing the exception to throw
        Returns:
        the value, if present
        Throws:
        E - when a value is not present
        E extends java.lang.Exception
      • mapIfPresent

        public <U> ResolutionResult<U> mapIfPresent​(java.util.function.BiFunction<java.lang.Boolean,​V,​U> transformer)
        Transform any present value of this resolution result.

        The up-to-date flag with be preserved from this.

        Type Parameters:
        U - the result value type
        Parameters:
        transformer - the transformer, accepting a value of ({@link #upToDate()}, {@link #get()})
        Returns:
        a transformed resolution result
      • isPresent

        public final boolean isPresent()
        Get whether a value is present.
        Returns:
        the value
      • upToDate

        public boolean upToDate()
        Get whether the result was already up to date at resolution time.

        If this return false, this indicates that the incoming artifact was out-of-date and any downstream artifacts should be invalidated.

        Not-found results will never be up-to-date.

        Returns:
        the up-to-date status
      • equals

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

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

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