public interface Result
A LensKit result, consisting of a score and an ID. Individual recommenders may subclass this component to provide more detailed results.
Implementations must create well-defined equality. However, instances of different implementations are not required or expected to be able to be equal to each other. Instances are not allowed to be equal if they have different IDs.
Modifier and Type | Method and Description |
---|---|
<T extends Result> |
as(java.lang.Class<T> type)
Convert this result to the specified type, if possible.
|
long |
getId()
Get the ID for the result.
|
double |
getScore()
Get the score (value) associated with this result.
|
boolean |
hasScore()
Query whether the result has a score.
|
long getId()
Get the ID for the result.
double getScore()
Get the score (value) associated with this result.
Double.NaN
if the result does not have a score).boolean hasScore()
Query whether the result has a score. This is equivalent to testing the return value of getScore()
with Double.isNaN(double)
, but may make the resulting code more readable.
true
if the result has a score.@Nullable <T extends Result> T as(@Nonnull java.lang.Class<T> type)
Convert this result to the specified type, if possible.
type
- The desired result type.T
- The desired result type.T
, or null
if the type cannot be cast. This may be done by casting this type, or by unwrapping wrapper result types.