Query refactoring: simplified generic types in IndicesQueriesRegistry and IndexQueryParseService

This commit is contained in:
javanna 2015-08-13 18:22:50 +02:00 committed by Luca Cavanna
parent babfea0ab7
commit c797445457
3 changed files with 7 additions and 7 deletions

View File

@ -118,7 +118,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
//norelease we might want to get rid of this as it was temporarily introduced for our default doToQuery impl
//seems to be used only in tests
public QueryParser<? extends QueryBuilder<? extends QueryBuilder>> queryParser(String name) {
public QueryParser<?> queryParser(String name) {
return indicesQueriesRegistry.queryParsers().get(name);
}

View File

@ -35,13 +35,13 @@ import java.util.Set;
public class IndicesQueriesRegistry extends AbstractComponent {
private ImmutableMap<String, QueryParser<? extends QueryBuilder<? extends QueryBuilder>>> queryParsers;
private ImmutableMap<String, QueryParser<?>> queryParsers;
@Inject
public IndicesQueriesRegistry(Settings settings, Set<QueryParser<? extends QueryBuilder<? extends QueryBuilder>>> injectedQueryParsers, NamedWriteableRegistry namedWriteableRegistry) {
public IndicesQueriesRegistry(Settings settings, Set<QueryParser<?>> injectedQueryParsers, NamedWriteableRegistry namedWriteableRegistry) {
super(settings);
Map<String, QueryParser<? extends QueryBuilder<? extends QueryBuilder>>> queryParsers = Maps.newHashMap();
for (QueryParser<? extends QueryBuilder<? extends QueryBuilder>> queryParser : injectedQueryParsers) {
Map<String, QueryParser<?>> queryParsers = Maps.newHashMap();
for (QueryParser<?> queryParser : injectedQueryParsers) {
for (String name : queryParser.names()) {
queryParsers.put(name, queryParser);
}
@ -56,7 +56,7 @@ public class IndicesQueriesRegistry extends AbstractComponent {
/**
* Returns all the registered query parsers
*/
public ImmutableMap<String, QueryParser<? extends QueryBuilder<? extends QueryBuilder>>> queryParsers() {
public ImmutableMap<String, QueryParser<?>> queryParsers() {
return queryParsers;
}
}

View File

@ -307,7 +307,7 @@ public abstract class BaseQueryTestCase<QB extends AbstractQueryBuilder<QB>> ext
try (BytesStreamOutput output = new BytesStreamOutput()) {
testQuery.writeTo(output);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
QueryBuilder<? extends QueryBuilder> prototype = queryParserService.queryParser(testQuery.getWriteableName()).getBuilderPrototype();
QueryBuilder<?> prototype = queryParserService.queryParser(testQuery.getWriteableName()).getBuilderPrototype();
QueryBuilder deserializedQuery = prototype.readFrom(in);
assertEquals(deserializedQuery, testQuery);
assertEquals(deserializedQuery.hashCode(), testQuery.hashCode());