public final class Results extends Object
Utility functions for working with results.
Modifier and Type  Method and Description 

static BasicResult 
basicCopy(Result r)
Create a basic result that has the same ID and score as another result (a basic copy of the result).

static Function<Result,BasicResult> 
basicCopyFunction()
Guava function that converts a result to a basic result.

static Equivalence<Result> 
basicEquivalence()
An equivalence relation that considers objects to be equal if they are equal after being converted to basic results (that is, their IDs and scores are equal).

static BasicResult 
create(long id,
double score)
Create a new result with just and ID and a score.

static BasicResult 
fromEntry(Map.Entry<Long,Double> entry)
Convert a map entry to a basic result.

static Function<Map.Entry<Long,Double>,Result> 
fromEntryFunction()
Function to convert map entries to basic results.

static Ordering<Result> 
idOrder()
Get an ordering (comparator) that orders results by ID.

static KeyExtractor<Result> 
keyExtractor()
Get a key extractor that extracts the result’s ID as its key.

static ResultList 
newResultList(List<? extends Result> results)
Create a new result list.

static <R extends Result> 
newResultList(R... results)
Create a new result list.

static ResultMap 
newResultMap(Iterable<? extends Result> results)
Create a new result list.

static <R extends Result> 
newResultMap(R... results)
Create a new result list.

static RescoredResult 
rescore(Result r,
double s)
Create a rescored result.

static RescoredResult 
rescore(Result orig,
Result score)
Create a rescored result with details.

static Ordering<Result> 
scoreOrder()
Get an ordering (comparator) that orders results by score.

public static BasicResult create(long id, double score)
Create a new result with just and ID and a score.
id
 The ID.score
 The score.public static BasicResult basicCopy(Result r)
Create a basic result that has the same ID and score as another result (a basic copy of the result).
r
 The result to copy.r
. This may be the same object as r
, since basic results are immutable.public static RescoredResult rescore(Result r, double s)
Create a rescored result.
r
 The result to score.s
 The new score.RescoredResult
that wraps r
with a new score of s
.public static RescoredResult rescore(@Nonnull Result orig, @Nullable Result score)
Create a rescored result with details.
orig
 The original result.score
 The new result, or null
for no score (the resulting result will have no score).@Nonnull public static ResultList newResultList(@Nonnull List<? extends Result> results)
Create a new result list.
results
 The results to include in the list.@SafeVarargs @Nonnull public static <R extends Result> ResultList newResultList(R... results)
Create a new result list.
results
 The results to include in the list.R
 the result type@Nonnull public static ResultMap newResultMap(@Nonnull Iterable<? extends Result> results)
Create a new result list.
results
 The results to include in the list.@SafeVarargs @Nonnull public static <R extends Result> ResultMap newResultMap(R... results)
Create a new result list.
results
 The results to include in the list.R
 the result typepublic static Function<Result,BasicResult> basicCopyFunction()
Guava function that converts a result to a basic result. This is just basicCopy(Result)
exposed as a Guava Function
for use in processing lists, etc.
public static BasicResult fromEntry(Map.Entry<Long,Double> entry)
Convert a map entry to a basic result.
entry
 The map entry.public static Function<Map.Entry<Long,Double>,Result> fromEntryFunction()
Function to convert map entries to basic results.
public static Equivalence<Result> basicEquivalence()
An equivalence relation that considers objects to be equal if they are equal after being converted to basic results (that is, their IDs and scores are equal).
public static Ordering<Result> idOrder()
Get an ordering (comparator) that orders results by ID.
public static Ordering<Result> scoreOrder()
Get an ordering (comparator) that orders results by score.
public static KeyExtractor<Result> keyExtractor()
Get a key extractor that extracts the result’s ID as its key.