generic for sub classes also?

This commit is contained in:
Britta Weber 2015-07-29 17:20:06 +02:00
parent 6754a26d08
commit b86d07fc9a
4 changed files with 13 additions and 12 deletions

View File

@ -285,12 +285,12 @@ public class PercolateContext extends SearchContext {
} }
@Override @Override
public FetchSubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory contextFactory) { public <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) {
String subPhaseName = contextFactory.getName(); String subPhaseName = contextFactory.getName();
if (subPhaseContexts.get(subPhaseName) == null) { if (subPhaseContexts.get(subPhaseName) == null) {
subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance()); subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance());
} }
return subPhaseContexts.get(subPhaseName); return (SubPhaseContext) subPhaseContexts.get(subPhaseName);
} }
// Unused: // Unused:

View File

@ -129,10 +129,10 @@ public class DefaultSearchContext extends SearchContext {
private final Map<String, FetchSubPhaseContext> subPhaseContexts = new HashMap<>(); private final Map<String, FetchSubPhaseContext> subPhaseContexts = new HashMap<>();
public DefaultSearchContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget, public DefaultSearchContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget,
Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard, Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard,
ScriptService scriptService, PageCacheRecycler pageCacheRecycler, ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
BigArrays bigArrays, Counter timeEstimateCounter, ParseFieldMatcher parseFieldMatcher, BigArrays bigArrays, Counter timeEstimateCounter, ParseFieldMatcher parseFieldMatcher,
TimeValue timeout TimeValue timeout
) { ) {
super(parseFieldMatcher); super(parseFieldMatcher);
this.id = id; this.id = id;
@ -305,14 +305,15 @@ public class DefaultSearchContext extends SearchContext {
} }
@Override @Override
public FetchSubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory contextFactory) { public <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) {
String subPhaseName = contextFactory.getName(); String subPhaseName = contextFactory.getName();
if (subPhaseContexts.get(subPhaseName) == null) { if (subPhaseContexts.get(subPhaseName) == null) {
subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance()); subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance());
} }
return subPhaseContexts.get(subPhaseName); return (SubPhaseContext) subPhaseContexts.get(subPhaseName);
} }
@Override @Override
public SearchContextHighlight highlight() { public SearchContextHighlight highlight() {
return highlight; return highlight;

View File

@ -621,7 +621,7 @@ public abstract class FilteredSearchContext extends SearchContext {
} }
@Override @Override
public FetchSubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory subPhase) { public <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) {
return in.getFetchSubPhaseContext(subPhase); return in.getFetchSubPhaseContext(contextFactory);
} }
} }

View File

@ -204,12 +204,12 @@ public class TestSearchContext extends SearchContext {
} }
@Override @Override
public FetchSubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory contextFactory) { public <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) {
String subPhaseName = contextFactory.getName(); String subPhaseName = contextFactory.getName();
if (subPhaseContexts.get(subPhaseName) == null) { if (subPhaseContexts.get(subPhaseName) == null) {
subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance()); subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance());
} }
return subPhaseContexts.get(subPhaseName); return (SubPhaseContext) subPhaseContexts.get(subPhaseName);
} }
@Override @Override