Skip to content

Commit e5a1c11

Browse files
committed
Use Java 7 diamond operator where possible
1 parent 2f79dc6 commit e5a1c11

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

modernizer-maven-plugin/src/main/java/org/gaul/modernizer_maven_plugin/ModernizerMojo.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public final class ModernizerMojo extends AbstractMojo {
176176
* java/lang/String.getBytes:(Ljava/lang/String;)[B.
177177
*/
178178
@Parameter
179-
protected Set<String> exclusions = new HashSet<String>();
179+
protected Set<String> exclusions = new HashSet<>();
180180

181181
/**
182182
* Violation patterns to disable. Each exclusion should be a
@@ -185,15 +185,15 @@ public final class ModernizerMojo extends AbstractMojo {
185185
* java/lang/.*
186186
*/
187187
@Parameter
188-
protected Set<String> exclusionPatterns = new HashSet<String>();
188+
protected Set<String> exclusionPatterns = new HashSet<>();
189189

190190
/**
191191
* Package prefixes to ignore, specified using &lt;ignorePackage&gt; child
192192
* elements. Specifying foo.bar subsequently ignores foo.bar.*,
193193
* foo.bar.baz.* and so on.
194194
*/
195195
@Parameter
196-
protected Set<String> ignorePackages = new HashSet<String>();
196+
protected Set<String> ignorePackages = new HashSet<>();
197197

198198
/**
199199
* Fully qualified class names (incl. package) to ignore by regular
@@ -203,7 +203,7 @@ public final class ModernizerMojo extends AbstractMojo {
203203
* ending in Immutable in all packages.
204204
*/
205205
@Parameter
206-
protected Set<String> ignoreClassNamePatterns = new HashSet<String>();
206+
protected Set<String> ignoreClassNamePatterns = new HashSet<>();
207207

208208
private Modernizer modernizer;
209209

@@ -234,13 +234,13 @@ public void execute() throws MojoExecutionException {
234234
allViolations.putAll(parseViolations(violationsFilePath));
235235
}
236236

237-
Set<String> allExclusions = new HashSet<String>();
237+
Set<String> allExclusions = new HashSet<>();
238238
allExclusions.addAll(exclusions);
239239
if (exclusionsFile != null) {
240240
allExclusions.addAll(readExclusionsFile(exclusionsFile));
241241
}
242242

243-
Set<Pattern> allExclusionPatterns = new HashSet<Pattern>();
243+
Set<Pattern> allExclusionPatterns = new HashSet<>();
244244
for (String pattern : exclusionPatterns) {
245245
try {
246246
allExclusionPatterns.add(Pattern.compile(pattern));
@@ -250,7 +250,7 @@ public void execute() throws MojoExecutionException {
250250
}
251251
}
252252

253-
Set<Pattern> allIgnoreFullClassNamePatterns = new HashSet<Pattern>();
253+
Set<Pattern> allIgnoreFullClassNamePatterns = new HashSet<>();
254254
for (String pattern : ignoreClassNamePatterns) {
255255
try {
256256
allIgnoreFullClassNamePatterns.add(Pattern.compile(pattern));
@@ -260,7 +260,7 @@ public void execute() throws MojoExecutionException {
260260
}
261261
}
262262

263-
Set<String> ignoreClassNames = new HashSet<String>();
263+
Set<String> ignoreClassNames = new HashSet<>();
264264
try {
265265
ignoreClassNames.addAll(
266266
SuppressModernizerAnnotationDetector.detect(

modernizer-maven-plugin/src/main/java/org/gaul/modernizer_maven_plugin/SuppressGeneratedAnnotationDetector.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
import org.objectweb.asm.ClassVisitor;
3232

3333
public final class SuppressGeneratedAnnotationDetector {
34-
private final Set<String> annotatedClassNames =
35-
new HashSet<String>();
36-
private final Set<String> allClassNames =
37-
new HashSet<String>();
34+
private final Set<String> annotatedClassNames = new HashSet<>();
35+
private final Set<String> allClassNames = new HashSet<>();
3836

3937
private SuppressGeneratedAnnotationDetector() { }
4038

@@ -46,8 +44,7 @@ public static Set<String> detect(Path path) throws IOException {
4644
}
4745

4846
private Set<String> computeSuppressedClassNames() {
49-
Set<String> suppressedClassNames =
50-
new HashSet<String>(annotatedClassNames);
47+
Set<String> suppressedClassNames = new HashSet<>(annotatedClassNames);
5148
for (String className : allClassNames) {
5249
if (suppressedClassNames.contains(className)) {
5350
continue;

modernizer-maven-plugin/src/main/java/org/gaul/modernizer_maven_plugin/SuppressModernizerAnnotationDetector.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@
3636
import org.objectweb.asm.TypePath;
3737

3838
public final class SuppressModernizerAnnotationDetector {
39-
private final Set<String> annotatedClassNames =
40-
new HashSet<String>();
41-
private final Set<String> allClassNames =
42-
new HashSet<String>();
39+
private final Set<String> annotatedClassNames = new HashSet<>();
40+
private final Set<String> allClassNames = new HashSet<>();
4341

4442
private SuppressModernizerAnnotationDetector() { }
4543

@@ -62,8 +60,7 @@ static Set<String> detect(Class<?>... classes) throws IOException {
6260
}
6361

6462
private Set<String> computeSuppressedClassNames() {
65-
Set<String> suppressedClassNames =
66-
new HashSet<String>(annotatedClassNames);
63+
Set<String> suppressedClassNames = new HashSet<>(annotatedClassNames);
6764
for (String className : allClassNames) {
6865
if (suppressedClassNames.contains(className)) {
6966
continue;

0 commit comments

Comments
 (0)