Class ResolutionResult<V>
- java.lang.Object
-
- org.spongepowered.gradle.vanilla.resolver.ResolutionResult<V>
-
- Type Parameters:
V- the result type
public final class ResolutionResult<V> extends java.lang.ObjectA 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResolutionResult.StatisticsRetrieve statistics about a collection of resolution results.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(@Nullable java.lang.Object other)Vget()Assert that this resolution has a result.inthashCode()booleanisPresent()Get whether a value is present.<U> ResolutionResult<U>mapIfPresent(java.util.function.BiFunction<java.lang.Boolean,V,U> transformer)Transform any present value of this resolution result.static <T> ResolutionResult<T>notFound()@Nullable VorElseNull()Get a result from this resolution action, if present.<E extends java.lang.Exception>
VorElseThrow(java.util.function.Supplier<E> exceptionSupplier)Get a present value from this result, or throw the provided exception.static <T> ResolutionResult<T>result(T result, boolean upToDate)static <T> java.util.stream.Collector<ResolutionResult<T>,ResolutionResult.Statistics,ResolutionResult.Statistics>statisticCollector()java.lang.StringtoString()booleanupToDate()Get whether the result was already up to date at resolution time.
-
-
-
Method Detail
-
notFound
public static <T> ResolutionResult<T> notFound()
-
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 presentE 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
statisticCollector
public static <T> java.util.stream.Collector<ResolutionResult<T>,ResolutionResult.Statistics,ResolutionResult.Statistics> statisticCollector()
-
-