Make consistent use of the diamond operator with generic types

This commit is contained in:
Andy Wilkinson
2016-01-26 11:14:29 +00:00
parent 08b24e0496
commit 02fa42445f
16 changed files with 45 additions and 46 deletions

View File

@@ -71,7 +71,7 @@ org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class CurlRequestSnippet extends TemplatedSnippet {
private static final Set<HeaderFilter> HEADER_FILTERS;
static {
Set<HeaderFilter> headerFilters = new HashSet<HeaderFilter>();
Set<HeaderFilter> headerFilters = new HashSet<>();
headerFilters.add(new NamedHeaderFilter(HttpHeaders.HOST));
headerFilters.add(new NamedHeaderFilter(HttpHeaders.CONTENT_LENGTH));
headerFilters.add(new BasicAuthHeaderFilter());
@@ -75,7 +75,7 @@ public class CurlRequestSnippet extends TemplatedSnippet {
@Override
protected Map<String, Object> createModel(Operation operation) {
Map<String, Object> model = new HashMap<String, Object>();
Map<String, Object> model = new HashMap<>();
model.put("url", getUrl(operation));
model.put("options", getOptions(operation));
return model;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet {
private void validateHeaderDocumentation(Operation operation) {
List<HeaderDescriptor> missingHeaders = findMissingHeaders(operation);
if (!missingHeaders.isEmpty()) {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
for (HeaderDescriptor headerDescriptor : missingHeaders) {
names.add(headerDescriptor.getName());
}
@@ -94,7 +94,7 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet {
* @return descriptors for the headers that are missing from the operation
*/
protected List<HeaderDescriptor> findMissingHeaders(Operation operation) {
List<HeaderDescriptor> missingHeaders = new ArrayList<HeaderDescriptor>();
List<HeaderDescriptor> missingHeaders = new ArrayList<>();
Set<String> actualHeaders = extractActualHeaders(operation);
for (HeaderDescriptor headerDescriptor : this.headerDescriptors) {
if (!headerDescriptor.isOptional()
@@ -132,7 +132,7 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet {
* @return the model
*/
protected Map<String, Object> createModelForDescriptor(HeaderDescriptor descriptor) {
Map<String, Object> model = new HashMap<String, Object>();
Map<String, Object> model = new HashMap<>();
model.put("name", descriptor.getName());
model.put("description", descriptor.getDescription());
model.put("optional", descriptor.isOptional());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public class HttpRequestSnippet extends TemplatedSnippet {
@Override
protected Map<String, Object> createModel(Operation operation) {
Map<String, Object> model = new HashMap<String, Object>();
Map<String, Object> model = new HashMap<>();
model.put("method", operation.getRequest().getMethod());
model.put(
"path",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ public class HttpResponseSnippet extends TemplatedSnippet {
protected Map<String, Object> createModel(Operation operation) {
OperationResponse response = operation.getResponse();
HttpStatus status = response.getStatus();
Map<String, Object> model = new HashMap<String, Object>();
Map<String, Object> model = new HashMap<>();
model.put("responseBody", responseBody(response));
model.put("statusCode", status.value());
model.put("statusReason", status.getReasonPhrase());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ public class LinksSnippet extends TemplatedSnippet {
private void validate(Map<String, List<Link>> links) {
Set<String> actualRels = links.keySet();
Set<String> undocumentedRels = new HashSet<String>(actualRels);
Set<String> undocumentedRels = new HashSet<>(actualRels);
undocumentedRels.removeAll(this.descriptorsByRel.keySet());
Set<String> requiredRels = new HashSet<>();
@@ -112,7 +112,7 @@ public class LinksSnippet extends TemplatedSnippet {
}
}
Set<String> missingRels = new HashSet<String>(requiredRels);
Set<String> missingRels = new HashSet<>(requiredRels);
missingRels.removeAll(actualRels);
if (!undocumentedRels.isEmpty() || !missingRels.isEmpty()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,7 +123,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
if (message.length() > 0) {
message += String.format("%n");
}
List<String> paths = new ArrayList<String>();
List<String> paths = new ArrayList<>();
for (FieldDescriptor fieldDescriptor : missingFields) {
paths.add(fieldDescriptor.getPath());
}
@@ -170,7 +170,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
* @return the model
*/
protected Map<String, Object> createModelForDescriptor(FieldDescriptor descriptor) {
Map<String, Object> model = new HashMap<String, Object>();
Map<String, Object> model = new HashMap<>();
model.put("path", descriptor.getPath());
model.put("type", descriptor.getType().toString());
model.put("description", descriptor.getDescription());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ class JsonContentHandler implements ContentHandler {
@Override
public List<FieldDescriptor> findMissingFields(List<FieldDescriptor> fieldDescriptors) {
List<FieldDescriptor> missingFields = new ArrayList<FieldDescriptor>();
List<FieldDescriptor> missingFields = new ArrayList<>();
Object payload = readContent();
for (FieldDescriptor fieldDescriptor : fieldDescriptors) {
if (!fieldDescriptor.isOptional()

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
final class JsonFieldProcessor {
boolean hasField(JsonFieldPath fieldPath, Object payload) {
final AtomicReference<Boolean> hasField = new AtomicReference<Boolean>(false);
final AtomicReference<Boolean> hasField = new AtomicReference<>(false);
traverse(new ProcessingContext(payload, fieldPath), new MatchCallback() {
@Override
@@ -45,7 +45,7 @@ final class JsonFieldProcessor {
}
Object extract(JsonFieldPath path, Object payload) {
final List<Object> matches = new ArrayList<Object>();
final List<Object> matches = new ArrayList<>();
traverse(new ProcessingContext(payload, path), new MatchCallback() {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,9 +84,9 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
private void verifyParameterDescriptors(Operation operation) {
Set<String> actualParameters = extractActualParameters(operation);
Set<String> expectedParameters = this.descriptorsByName.keySet();
Set<String> undocumentedParameters = new HashSet<String>(actualParameters);
Set<String> undocumentedParameters = new HashSet<>(actualParameters);
undocumentedParameters.removeAll(expectedParameters);
Set<String> missingParameters = new HashSet<String>(expectedParameters);
Set<String> missingParameters = new HashSet<>(expectedParameters);
missingParameters.removeAll(actualParameters);
if (!undocumentedParameters.isEmpty() || !missingParameters.isEmpty()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -174,7 +174,7 @@ public class LinksSnippetTests {
private static class StubLinkExtractor implements LinkExtractor {
private MultiValueMap<String, Link> linksByRel = new LinkedMultiValueMap<String, Link>();
private MultiValueMap<String, Link> linksByRel = new LinkedMultiValueMap<>();
@Override
public MultiValueMap<String, Link> extractLinks(OperationResponse response)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,22 +138,22 @@ public class JsonFieldProcessorTests {
@Test(expected = FieldDoesNotExistException.class)
public void nonExistentNestedField() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
payload.put("a", new HashMap<String, Object>());
this.fieldProcessor.extract(JsonFieldPath.compile("a.b"), payload);
}
@Test(expected = FieldDoesNotExistException.class)
public void nonExistentNestedFieldWhenParentIsNotAMap() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
payload.put("a", 5);
this.fieldProcessor.extract(JsonFieldPath.compile("a.b"), payload);
}
@Test(expected = FieldDoesNotExistException.class)
public void nonExistentFieldWhenParentIsAnArray() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> alpha = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
HashMap<String, Object> alpha = new HashMap<>();
alpha.put("b", Arrays.asList(new HashMap<String, Object>()));
payload.put("a", alpha);
this.fieldProcessor.extract(JsonFieldPath.compile("a.b.c"), payload);
@@ -161,21 +161,21 @@ public class JsonFieldProcessorTests {
@Test(expected = FieldDoesNotExistException.class)
public void nonExistentArrayField() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
this.fieldProcessor.extract(JsonFieldPath.compile("a[]"), payload);
}
@Test(expected = FieldDoesNotExistException.class)
public void nonExistentArrayFieldAsTypeDoesNotMatch() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
payload.put("a", 5);
this.fieldProcessor.extract(JsonFieldPath.compile("a[]"), payload);
}
@Test(expected = FieldDoesNotExistException.class)
public void nonExistentFieldBeneathAnArray() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> alpha = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
HashMap<String, Object> alpha = new HashMap<>();
alpha.put("b", Arrays.asList(new HashMap<String, Object>()));
payload.put("a", alpha);
this.fieldProcessor.extract(JsonFieldPath.compile("a.b[].id"), payload);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public class OutputCapture implements TestRule {
private ByteArrayOutputStream capturedOutput;
private List<Matcher<? super String>> matchers = new ArrayList<Matcher<? super String>>();
private List<Matcher<? super String>> matchers = new ArrayList<>();
@Override
public Statement apply(final Statement base, Description description) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ public final class SnippetMatchers {
private static abstract class AbstractSnippetContentMatcher extends
BaseMatcher<String> {
private List<String> lines = new ArrayList<String>();
private List<String> lines = new ArrayList<>();
protected void addLine(String line) {
this.lines.add(line);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ final class IterableEnumeration<T> implements Iterable<T> {
* @return the iterable
*/
static <T> Iterable<T> iterable(Enumeration<T> enumeration) {
return new IterableEnumeration<T>(enumeration);
return new IterableEnumeration<>(enumeration);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -430,8 +430,7 @@ public class MockMvcRestDocumentationIntegrationTests {
response.put("links", Arrays.asList(new Link("rel", "href")));
HttpHeaders headers = new HttpHeaders();
headers.add("a", "alpha");
return new ResponseEntity<Map<String, Object>>(response, headers,
HttpStatus.OK);
return new ResponseEntity<>(response, headers, HttpStatus.OK);
}
@RequestMapping(value = "/company/5", produces = MediaType.APPLICATION_JSON_VALUE)