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<?>> Represents an individual search result.Search result minimally have a type and ID and may have their result object populated at a later time via setResultObject(Identifiable).Results have a score and possibly number of highlights. Two results are considered equal if they have the same type and ID. You may use a SearchResultSetto combine results in a sensible way, retaining result objects and highlights when a better result is added.- Author:
- paul, poirigui
- See Also:
- SearchSource,- SearchResultSet
 
- 
- 
Constructor SummaryConstructors Constructor Description SearchResult()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearResultObject()Clear the result object.intcompareTo(SearchResult<?> o)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, Map<String,String> highlights, Object source)Create a search result from a given identifiable entity.LonggetResultId()Obtain the result ID.voidsetResultObject(T resultObject)Set the result object.StringtoString()SearchResult<T>withHighlights(Map<String,String> highlights)Copy this search result with the given highlights.<S extends Identifiable>
 SearchResult<S>withResultObject(S resultObject)Create a search result from an existing one, replacing the result object with the target one.
 
- 
- 
- 
Method Detail- 
frompublic 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 from a given identifiable entity.The result can be cleared later with clearResultObject().
 - 
frompublic 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.The result can be set later with setResultObject(Identifiable).
 - 
compareTopublic int compareTo(SearchResult<?> o) - Specified by:
- compareToin interface- Comparable<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.
 - 
setResultObjectpublic void setResultObject(T resultObject) Set the result object.- Throws:
- IllegalArgumentException- if the provided result object is null or if its ID differs from- getResultId().
 
 - 
clearResultObjectpublic void clearResultObject() Clear the result object.
 - 
withResultObjectpublic <S extends Identifiable> SearchResult<S> withResultObject(@Nullable S resultObject) Create a search result from an existing one, replacing the result object with the target one.The new result object does not have to be of the same type as the original result object. This is useful if you need to convert the result object (i.e. to a VO) while preserving the metadata (score, highlighted text, etc.). 
 - 
withHighlightspublic SearchResult<T> withHighlights(Map<String,String> highlights) Copy this search result with the given highlights.
 
- 
 
-