Package ubic.gemma.core.search
Class SearchResult<T extends Identifiable>
- java.lang.Object
-
- ubic.gemma.core.search.SearchResult<T>
-
- All Implemented Interfaces:
Comparable<SearchResult<?>>
public class SearchResult<T extends Identifiable> extends Object implements Comparable<SearchResult<?>>
- Author:
- paul
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(SearchResult<?> o)static <T extends Identifiable>
SearchResult<T>from(Class<? extends Identifiable> resultType, long entityId, double score, Object source)static <T extends Identifiable>
SearchResult<T>from(Class<? extends Identifiable> resultType, long entityId, double score, Map<String,String> highlights, Object source)Create a new provisional search result with a result type and ID.static <T extends Identifiable>
SearchResult<T>from(Class<? extends Identifiable> resultType, T entity, double score, Object source)Shorthand for#from(Class, Identifiable, double, String, Object)if you don't need to set the score and highlighted text.static <T extends Identifiable>
SearchResult<T>from(Class<? extends Identifiable> resultType, T entity, double score, Map<String,String> highlights, Object source)Create a search result whose result class differ from the object.static <T extends Identifiable>
SearchResult<T>from(SearchResult<?> original, T newResultObject)Create a search result from an existing one, replacing the result object with the target one.static Comparator<SearchResult<?>>getComparator()Obtain a comparator for this search result.LonggetResultId()Obtain the result ID.voidsetResultObject(T resultObject)Set the result object.
-
-
-
Method Detail
-
getComparator
public static Comparator<SearchResult<?>> getComparator()
Obtain a comparator for this search result.Results are compared by
#getScore()in descending order. Note that any search result can be compared regardless of their result type or result object.
-
from
public static <T extends Identifiable> SearchResult<T> from(Class<? extends Identifiable> resultType, T entity, double score, @Nullable Map<String,String> highlights, Object source)
Create a search result whose result class differ from the object.This can be useful if you wrap a proxy, or don't want to expose the object class publicly. For example, our
PhenotypeAssociationuse aCharacteristicValueObjectfor the result object.
-
from
public static <T extends Identifiable> SearchResult<T> from(Class<? extends Identifiable> resultType, T entity, double score, Object source)
Shorthand for#from(Class, Identifiable, double, String, Object)if you don't need to set the score and highlighted text.
-
from
public static <T extends Identifiable> SearchResult<T> from(Class<? extends Identifiable> resultType, long entityId, double score, @Nullable Map<String,String> highlights, Object source)
Create a new provisional search result with a result type and ID.
-
from
public static <T extends Identifiable> SearchResult<T> from(Class<? extends Identifiable> resultType, long entityId, double score, Object source)
-
from
public static <T extends Identifiable> SearchResult<T> from(SearchResult<?> original, @Nullable T newResultObject)
Create a search result from an existing one, replacing the result object with the target one.This is useful if you need to convert the result object (i.e. to a VO) while preserving the metadata (score, highlighted text, etc.).
-
compareTo
public int compareTo(SearchResult<?> o)
- Specified by:
compareToin interfaceComparable<T extends Identifiable>
-
getResultId
@Nonnull public Long getResultId()
Obtain the result ID.For consistency with
Identifiable.getId(), thus returns aLong. It is however backed internally by a native long and cannot ever be null.
-
setResultObject
public void setResultObject(@Nullable T resultObject)
Set the result object.- Throws:
IllegalArgumentException- if the provided result object IDs differs fromgetResultId().
-
-