net.conquiris.api.search
Class ItemResult<T>

java.lang.Object
  extended by net.conquiris.api.search.Result
      extended by net.conquiris.api.search.ItemResult<T>
Type Parameters:
T - Item type.
All Implemented Interfaces:
Serializable

public final class ItemResult<T>
extends Result

Result representing a single item.

Author:
Andres Rodriguez
See Also:
Serialized Form

Method Summary
static
<T> ItemResult<T>
empty()
          Returns the empty item.
 boolean equals(Object obj)
           
static
<T> ItemResult<T>
found(int totalHits, float maxScore, long time, T item)
          Returns a found item.
 T getItem()
          Returns the item.
 int hashCode()
           
 boolean isFound()
          Returns whether the item was found.
static
<T> ItemResult<T>
notFound(long time)
          Returns a not found item.
 
Methods inherited from class net.conquiris.api.search.Result
getMaxScore, getTime, getTotalHits
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

empty

public static <T> ItemResult<T> empty()
Returns the empty item.

Returns:
The empty item.

notFound

public static <T> ItemResult<T> notFound(long time)
Returns a not found item.

Parameters:
time - Time taken by the query (ms).

found

public static <T> ItemResult<T> found(int totalHits,
                                      float maxScore,
                                      long time,
                                      T item)
Returns a found item.

Parameters:
totalHits - Number of hits.
maxScore - Maximum score.
time - Time taken by the query (ms).
item - Found item.

isFound

public boolean isFound()
Returns whether the item was found.


getItem

public T getItem()
Returns the item. Will be null iff totalHits = 0

Returns:
The found item.
Throws:
IllegalStateException - if the item was not found.

equals

public boolean equals(Object obj)
Overrides:
equals in class Result

hashCode

public int hashCode()
Overrides:
hashCode in class Result


Copyright © 2012 Derquinse Projects.. All Rights Reserved.