Skip to content

Commit 4c7dd49

Browse files
committed
DATAES-328 - Replace explicit generics with diamond operator.
1 parent 0cada7f commit 4c7dd49

32 files changed

+203
-162
lines changed

src/main/java/org/springframework/data/elasticsearch/core/CriteriaFilterProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ class CriteriaFilterProcessor {
4545

4646

4747
QueryBuilder createFilterFromCriteria(Criteria criteria) {
48-
List<QueryBuilder> fbList = new LinkedList<QueryBuilder>();
48+
List<QueryBuilder> fbList = new LinkedList<>();
4949
QueryBuilder filter = null;
5050

5151
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
@@ -86,7 +86,7 @@ QueryBuilder createFilterFromCriteria(Criteria criteria) {
8686

8787
private List<QueryBuilder> createFilterFragmentForCriteria(Criteria chainedCriteria) {
8888
Iterator<Criteria.CriteriaEntry> it = chainedCriteria.getFilterCriteriaEntries().iterator();
89-
List<QueryBuilder> filterList = new LinkedList<QueryBuilder>();
89+
List<QueryBuilder> filterList = new LinkedList<>();
9090

9191
String fieldName = chainedCriteria.getField().getName();
9292
Assert.notNull(fieldName, "Unknown field");
@@ -235,7 +235,7 @@ private void twoParameterBBox(GeoBoundingBoxQueryBuilder filter, Object[] values
235235
}
236236

237237
private List<QueryBuilder> buildNegationFilter(String fieldName, Iterator<Criteria.CriteriaEntry> it) {
238-
List<QueryBuilder> notFilterList = new LinkedList<QueryBuilder>();
238+
List<QueryBuilder> notFilterList = new LinkedList<>();
239239

240240
while (it.hasNext()) {
241241
Criteria.CriteriaEntry criteriaEntry = it.next();

src/main/java/org/springframework/data/elasticsearch/core/CriteriaQueryProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,9 +46,9 @@ QueryBuilder createQueryFromCriteria(Criteria criteria) {
4646
if (criteria == null)
4747
return null;
4848

49-
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
50-
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
51-
List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();
49+
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<>();
50+
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<>();
51+
List<QueryBuilder> mustQueryBuilderList = new LinkedList<>();
5252

5353
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
5454

src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public DefaultResultMapper(
7979
@Override
8080
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
8181
long totalHits = response.getHits().totalHits();
82-
List<T> results = new ArrayList<T>();
82+
List<T> results = new ArrayList<>();
8383
for (SearchHit hit : response.getHits()) {
8484
if (hit != null) {
8585
T result = null;
@@ -94,7 +94,7 @@ public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz,
9494
}
9595
}
9696

97-
return new AggregatedPageImpl<T>(results, pageable, totalHits, response.getAggregations());
97+
return new AggregatedPageImpl<>(results, pageable, totalHits, response.getAggregations());
9898
}
9999

100100
private <T> void populateScriptFields(T result, SearchHit hit) {
@@ -160,7 +160,7 @@ public <T> T mapResult(GetResponse response, Class<T> clazz) {
160160

161161
@Override
162162
public <T> LinkedList<T> mapResults(MultiGetResponse responses, Class<T> clazz) {
163-
LinkedList<T> list = new LinkedList<T>();
163+
LinkedList<T> list = new LinkedList<>();
164164
for (MultiGetItemResponse response : responses.getResponses()) {
165165
if (!response.isFailed() && response.getResponse().isExists()) {
166166
T result = mapEntity(response.getResponse().getSourceAsString(), clazz);

src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public void bulkIndex(List<IndexQuery> queries) {
604604
}
605605
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
606606
if (bulkResponse.hasFailures()) {
607-
Map<String, String> failedDocuments = new HashMap<String, String>();
607+
Map<String, String> failedDocuments = new HashMap<>();
608608
for (BulkItemResponse item : bulkResponse.getItems()) {
609609
if (item.isFailed())
610610
failedDocuments.put(item.getId(), item.getFailureMessage());
@@ -624,7 +624,7 @@ public void bulkUpdate(List<UpdateQuery> queries) {
624624
}
625625
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
626626
if (bulkResponse.hasFailures()) {
627-
Map<String, String> failedDocuments = new HashMap<String, String>();
627+
Map<String, String> failedDocuments = new HashMap<>();
628628
for (BulkItemResponse item : bulkResponse.getItems()) {
629629
if (item.isFailed())
630630
failedDocuments.put(item.getId(), item.getFailureMessage());
@@ -694,19 +694,19 @@ public <T> void delete(DeleteQuery deleteQuery, Class<T> clazz) {
694694
String scrollId = scan(searchQuery, scrollTimeInMillis, true);
695695

696696
BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
697-
List<String> ids = new ArrayList<String>();
697+
List<String> ids = new ArrayList<>();
698698
boolean hasRecords = true;
699699
while (hasRecords) {
700700
Page<String> page = scroll(scrollId, scrollTimeInMillis, new SearchResultMapper() {
701701
@Override
702702
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
703-
List<String> result = new ArrayList<String>();
703+
List<String> result = new ArrayList<>();
704704
for (SearchHit searchHit : response.getHits()) {
705705
String id = searchHit.getId();
706706
result.add(id);
707707
}
708708
if (result.size() > 0) {
709-
return new AggregatedPageImpl<T>((List<T>) result);
709+
return new AggregatedPageImpl<>((List<T>) result);
710710
}
711711
return null;
712712
}
@@ -1169,7 +1169,7 @@ private String[] retrieveTypeFromPersistentEntity(Class clazz) {
11691169
}
11701170

11711171
private List<String> extractIds(SearchResponse response) {
1172-
List<String> ids = new ArrayList<String>();
1172+
List<String> ids = new ArrayList<>();
11731173
for (SearchHit hit : response.getHits()) {
11741174
if (hit != null) {
11751175
ids.add(hit.getId());

src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@
4747
public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedPage<T>, AggregatedPage<T> {
4848

4949
private List<FacetResult> facets;
50-
private Map<String, FacetResult> mapOfFacets = new HashMap<String, FacetResult>();
50+
private Map<String, FacetResult> mapOfFacets = new HashMap<>();
5151

5252
public FacetedPageImpl(List<T> content) {
5353
super(content);
@@ -85,18 +85,18 @@ private void addFacet(FacetResult facetResult) {
8585
*/
8686
private void processAggregations() {
8787
if (facets == null) {
88-
facets = new ArrayList<FacetResult>();
88+
facets = new ArrayList<>();
8989
for (Aggregation agg : getAggregations()) {
9090
if (agg instanceof Terms) {
91-
List<Term> terms = new ArrayList<Term>();
91+
List<Term> terms = new ArrayList<>();
9292
for (Terms.Bucket t : ((Terms) agg).getBuckets()) {
9393
terms.add(new Term(t.getKeyAsString(), t.getDocCount()));
9494
}
9595
addFacet(new TermResult(agg.getName(), terms, terms.size(), ((Terms) agg).getSumOfOtherDocCounts(), 0));
9696
}
9797
if (agg instanceof Range) {
9898
List<? extends Range.Bucket> buckets = ((Range) agg).getBuckets();
99-
List<org.springframework.data.elasticsearch.core.facet.result.Range> ranges = new ArrayList<org.springframework.data.elasticsearch.core.facet.result.Range>();
99+
List<org.springframework.data.elasticsearch.core.facet.result.Range> ranges = new ArrayList<>();
100100
for (Range.Bucket b : buckets) {
101101
ExtendedStats rStats = (ExtendedStats) b.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
102102
if (rStats != null) {
@@ -113,7 +113,7 @@ private void processAggregations() {
113113
addFacet(new StatisticalResult(agg.getName(), stats.getCount(), stats.getMax(), stats.getMin(), stats.getAvg(), stats.getStdDeviation(), stats.getSumOfSquares(), stats.getSum(), stats.getVariance()));
114114
}
115115
if (agg instanceof Histogram) {
116-
List<IntervalUnit> intervals = new ArrayList<IntervalUnit>();
116+
List<IntervalUnit> intervals = new ArrayList<>();
117117
for (Histogram.Bucket h : ((Histogram) agg).getBuckets()) {
118118
ExtendedStats hStats = (ExtendedStats) h.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
119119
if (hStats != null) {

src/main/java/org/springframework/data/elasticsearch/core/MappingBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, bool
167167

168168
private static java.lang.reflect.Field[] retrieveFields(Class clazz) {
169169
// Create list of fields.
170-
List<java.lang.reflect.Field> fields = new ArrayList<java.lang.reflect.Field>();
170+
List<java.lang.reflect.Field> fields = new ArrayList<>();
171171

172172
// Keep backing up the inheritance hierarchy.
173173
Class targetClass = clazz;

src/main/java/org/springframework/data/elasticsearch/core/aggregation/impl/AggregatedPageImpl.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.springframework.data.elasticsearch.core.aggregation.impl;
217

318
import java.util.HashMap;
@@ -18,7 +33,7 @@
1833
public class AggregatedPageImpl<T> extends FacetedPageImpl<T> implements AggregatedPage<T> {
1934

2035
private Aggregations aggregations;
21-
private Map<String, Aggregation> mapOfAggregations = new HashMap<String, Aggregation>();
36+
private Map<String, Aggregation> mapOfAggregations = new HashMap<>();
2237

2338
public AggregatedPageImpl(List<T> content) {
2439
super(content);

src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class RangeFacetRequest extends AbstractFacetRequest {
4141
private String keyField;
4242
private String valueField;
4343

44-
private List<Entry> entries = new ArrayList<Entry>();
44+
private List<Entry> entries = new ArrayList<>();
4545

4646
public RangeFacetRequest(String name) {
4747
super(name);

src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchMappingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class SimpleElasticsearchMappingContext extends
3737

3838
@Override
3939
protected <T> SimpleElasticsearchPersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) {
40-
final SimpleElasticsearchPersistentEntity<T> persistentEntity = new SimpleElasticsearchPersistentEntity<T>(
40+
final SimpleElasticsearchPersistentEntity<T> persistentEntity = new SimpleElasticsearchPersistentEntity<>(
4141
typeInformation);
4242
if (context != null) {
4343
persistentEntity.setApplicationContext(context);

src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
public class SimpleElasticsearchPersistentProperty extends
3535
AnnotationBasedPersistentProperty<ElasticsearchPersistentProperty> implements ElasticsearchPersistentProperty {
3636

37-
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<Class<?>>();
38-
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<String>();
37+
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<>();
38+
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<>();
3939

4040
static {
4141
SUPPORTED_ID_TYPES.add(String.class);

src/main/java/org/springframework/data/elasticsearch/core/query/AbstractQuery.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ abstract class AbstractQuery implements Query {
3535

3636
protected Pageable pageable = DEFAULT_PAGE;
3737
protected Sort sort;
38-
protected List<String> indices = new ArrayList<String>();
39-
protected List<String> types = new ArrayList<String>();
40-
protected List<String> fields = new ArrayList<String>();
38+
protected List<String> indices = new ArrayList<>();
39+
protected List<String> types = new ArrayList<>();
40+
protected List<String> fields = new ArrayList<>();
4141
protected SourceFilter sourceFilter;
4242
protected float minScore;
4343
protected Collection<String> ids;

src/main/java/org/springframework/data/elasticsearch/core/query/Criteria.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,11 +57,11 @@ public String toString() {
5757
private float boost = Float.NaN;
5858
private boolean negating = false;
5959

60-
private List<Criteria> criteriaChain = new ArrayList<Criteria>(1);
60+
private List<Criteria> criteriaChain = new ArrayList<>(1);
6161

62-
private Set<CriteriaEntry> queryCriteria = new LinkedHashSet<CriteriaEntry>();
62+
private Set<CriteriaEntry> queryCriteria = new LinkedHashSet<>();
6363

64-
private Set<CriteriaEntry> filterCriteria = new LinkedHashSet<CriteriaEntry>();
64+
private Set<CriteriaEntry> filterCriteria = new LinkedHashSet<>();
6565

6666
public Criteria() {
6767
}

src/main/java/org/springframework/data/elasticsearch/core/query/MoreLikeThisQuery.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,20 +29,19 @@
2929
* @author Rizwan Idrees
3030
* @author Mohsin Husen
3131
*/
32-
3332
public class MoreLikeThisQuery {
3433

3534
private String id;
3635
private String indexName;
3736
private String type;
38-
private List<String> searchIndices = new ArrayList<String>();
39-
private List<String> searchTypes = new ArrayList<String>();
40-
private List<String> fields = new ArrayList<String>();
37+
private List<String> searchIndices = new ArrayList<>();
38+
private List<String> searchTypes = new ArrayList<>();
39+
private List<String> fields = new ArrayList<>();
4140
private String routing;
4241
private Float percentTermsToMatch;
4342
private Integer minTermFreq;
4443
private Integer maxQueryTerms;
45-
private List<String> stopWords = new ArrayList<String>();
44+
private List<String> stopWords = new ArrayList<>();
4645
private Integer minDocFreq;
4746
private Integer maxDocFreq;
4847
private Integer minWordLen;

src/main/java/org/springframework/data/elasticsearch/core/query/NativeSearchQuery.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
3838
private QueryBuilder query;
3939
private QueryBuilder filter;
4040
private List<SortBuilder> sorts;
41-
private final List<ScriptField> scriptFields = new ArrayList<ScriptField>();
41+
private final List<ScriptField> scriptFields = new ArrayList<>();
4242
private List<FacetRequest> facets;
4343
private List<AbstractAggregationBuilder> aggregations;
4444
private HighlightBuilder.Field[] highlightFields;
@@ -97,7 +97,7 @@ public void addScriptField(ScriptField... scriptField) {
9797

9898
public void addFacet(FacetRequest facetRequest) {
9999
if (facets == null) {
100-
facets = new ArrayList<FacetRequest>();
100+
facets = new ArrayList<>();
101101
}
102102
facets.add(facetRequest);
103103
}
@@ -119,7 +119,7 @@ public List<AbstractAggregationBuilder> getAggregations() {
119119

120120
public void addAggregation(AbstractAggregationBuilder aggregationBuilder) {
121121
if (aggregations == null) {
122-
aggregations = new ArrayList<AbstractAggregationBuilder>();
122+
aggregations = new ArrayList<>();
123123
}
124124
aggregations.add(aggregationBuilder);
125125
}

src/main/java/org/springframework/data/elasticsearch/core/query/NativeSearchQueryBuilder.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,15 +34,14 @@
3434
* @author Mohsin Husen
3535
* @author Artur Konczak
3636
*/
37-
3837
public class NativeSearchQueryBuilder {
3938

4039
private QueryBuilder queryBuilder;
4140
private QueryBuilder filterBuilder;
42-
private List<ScriptField> scriptFields = new ArrayList<ScriptField>();
43-
private List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>();
44-
private List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
45-
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<AbstractAggregationBuilder>();
41+
private List<ScriptField> scriptFields = new ArrayList<>();
42+
private List<SortBuilder> sortBuilders = new ArrayList<>();
43+
private List<FacetRequest> facetRequests = new ArrayList<>();
44+
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<>();
4645
private HighlightBuilder.Field[] highlightFields;
4746
private Pageable pageable;
4847
private String[] indices;
@@ -161,11 +160,11 @@ public NativeSearchQuery build() {
161160
if (sourceFilter != null) {
162161
nativeSearchQuery.addSourceFilter(sourceFilter);
163162
}
164-
163+
165164
if(indicesBoost != null) {
166165
nativeSearchQuery.setIndicesBoost(indicesBoost);
167166
}
168-
167+
169168
if (!isEmpty(scriptFields)) {
170169
nativeSearchQuery.setScriptFields(scriptFields);
171170
}

0 commit comments

Comments
 (0)