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

@ -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