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
public FetchSubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory contextFactory) {
public <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) {
String subPhaseName = contextFactory.getName();
if (subPhaseContexts.get(subPhaseName) == null) {
subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance());
}
return subPhaseContexts.get(subPhaseName);
return (SubPhaseContext) subPhaseContexts.get(subPhaseName);
}
// Unused:

View File

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

View File

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

View File

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