Skip to content

Commit cd61b17

Browse files
authored
Cleanup redundant specification of type parameters (#320)
Signed-off-by: Sven Strickroth <[email protected]>
1 parent 3c86741 commit cd61b17

16 files changed

+28
-28
lines changed

src/main/java/org/owasp/html/CssTokens.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ void lex() {
427427
sb.setLength(0);
428428
if (pos == cssLimit) { return; }
429429

430-
tokenTypes = new ArrayList<TokenType>();
430+
tokenTypes = new ArrayList<>();
431431

432432
@SuppressWarnings("hiding") // final
433433
String css = this.css;

src/main/java/org/owasp/html/Handler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface Handler<T> {
4343
void handle(T x);
4444

4545
/** A handler that does nothing given any input. */
46-
public static final Handler<Object> DO_NOTHING = new Handler<Object>() {
46+
public static final Handler<Object> DO_NOTHING = new Handler<>() {
4747
public void handle(Object x) {
4848
// Really, do nothing.
4949
}

src/main/java/org/owasp/html/HtmlChangeReporter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public HtmlChangeReporter(
6262
HtmlStreamEventReceiver renderer,
6363
HtmlChangeListener<? super T> listener, @Nullable T context) {
6464
this.output = new OutputChannel(renderer);
65-
this.input = new InputChannel<T>(output, listener, context);
65+
this.input = new InputChannel<>(output, listener, context);
6666
}
6767

6868
/**
@@ -149,7 +149,7 @@ public void text(String textChunk) {
149149
private static final class OutputChannel implements HtmlStreamEventReceiver {
150150
private final HtmlStreamEventReceiver renderer;
151151
String expectedElementName;
152-
Set<String> expectedAttrNames = new LinkedHashSet<String>();
152+
Set<String> expectedAttrNames = new LinkedHashSet<>();
153153

154154
OutputChannel(HtmlStreamEventReceiver renderer) {
155155
this.renderer = renderer;

src/main/java/org/owasp/html/HtmlElementTables.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public enum TextContentModelBit {
721721
}
722722

723723
static final Comparator<int[]> COMPARE_BY_ZEROTH =
724-
new Comparator<int[]>() {
724+
new Comparator<>() {
725725
public int compare(int[] a, int[] b) {
726726
return Integer.compare(a[0], b[0]);
727727
}

src/main/java/org/owasp/html/HtmlEntities.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,7 @@ final class HtmlEntities {
22932293

22942294
final Map<String, String> entityNameToCodePointMap = Collections.unmodifiableMap(builder);
22952295

2296-
ENTITY_TRIE = new Trie<String>(entityNameToCodePointMap);
2296+
ENTITY_TRIE = new Trie<>(entityNameToCodePointMap);
22972297
LONGEST_ENTITY_NAME = longestEntityName;
22982298
}
22992299

src/main/java/org/owasp/html/HtmlPolicyBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ public String apply(String elementName, List<String> attrs) {
10381038
relValue = DEFAULT_RELS_ON_TARGETTED_LINKS_STR;
10391039
} else {
10401040
StringBuilder sb = new StringBuilder();
1041-
Set<String> present = new HashSet<String>();
1041+
Set<String> present = new HashSet<>();
10421042
if (relIndex >= 0) {
10431043
// Preserve values that are not explicitly skipped.
10441044
String rels = attrs.get(relIndex);

src/main/java/org/owasp/html/Joinable.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static abstract class JoinHelper<T, SJ extends Joinable<SJ>> {
4343
final T zeroValue;
4444
final T identityValue;
4545
private Map<JoinStrategy<SJ>, Set<SJ>> requireSpecialJoining;
46-
private Set<T> uniq = new LinkedHashSet<T>();
46+
private Set<T> uniq = new LinkedHashSet<>();
4747

4848
JoinHelper(
4949
Class<T> baseType,
@@ -74,11 +74,11 @@ void unroll(T x) {
7474
JoinStrategy<SJ> strategy = sj.getJoinStrategy();
7575

7676
if (requireSpecialJoining == null) {
77-
requireSpecialJoining = new LinkedHashMap<Joinable.JoinStrategy<SJ>, Set<SJ>>();
77+
requireSpecialJoining = new LinkedHashMap<>();
7878
}
7979
Set<SJ> toJoinTogether = requireSpecialJoining.get(strategy);
8080
if (toJoinTogether == null) {
81-
toJoinTogether = new LinkedHashSet<SJ>();
81+
toJoinTogether = new LinkedHashSet<>();
8282
requireSpecialJoining.put(strategy, toJoinTogether);
8383
}
8484

src/main/java/org/owasp/html/PolicyFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public <CTX> HtmlSanitizer.Policy apply(
9696
if (listener == null) {
9797
return apply(out);
9898
} else {
99-
HtmlChangeReporter<CTX> r = new HtmlChangeReporter<CTX>(
99+
HtmlChangeReporter<CTX> r = new HtmlChangeReporter<>(
100100
out, listener, context);
101101
r.setPolicy(apply(r.getWrappedRenderer()));
102102
return r.getWrappedPolicy();

src/main/java/org/owasp/html/Trie.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ private Trie(
106106
char ch = elements.get(i).getKey().charAt(depth);
107107
if (ch != lastCh) {
108108
childMap[childIndex] = lastCh;
109-
children[childIndex++] = new Trie<T>(
109+
children[childIndex++] = new Trie<>(
110110
elements, depth + 1, childStart, i);
111111
childStart = i;
112112
lastCh = ch;
113113
}
114114
}
115115
childMap[childIndex] = lastCh;
116-
children[childIndex++] = new Trie<T>(elements, depth + 1, childStart, end);
116+
children[childIndex++] = new Trie<>(elements, depth + 1, childStart, end);
117117
}
118118

119119
/** Does this node correspond to a complete string in the input set. */
@@ -151,8 +151,8 @@ public boolean contains(char ch) {
151151

152152
private static <U> List<Map.Entry<String, U>> sortedUniqEntries(
153153
Map<String, U> m) {
154-
return new ArrayList<Map.Entry<String, U>>(
155-
new TreeMap<String, U>(m).entrySet());
154+
return new ArrayList<>(
155+
new TreeMap<>(m).entrySet());
156156
}
157157

158158
private static final char[] ZERO_CHARS = new char[0];

src/main/java/org/owasp/html/examples/UrlTextExample.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class UrlTextExample {
4949

5050
/** An event receiver that emits the domain of a link or image after it. */
5151
static class AppendDomainAfterText extends HtmlStreamEventReceiverWrapper {
52-
private final List<String> pendingText = new ArrayList<String>();
52+
private final List<String> pendingText = new ArrayList<>();
5353

5454
AppendDomainAfterText(HtmlStreamEventReceiver underlying) {
5555
super(underlying);

src/test/java/org/owasp/html/Benchmark.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private static String sanitize(String html) {
147147
StringBuilder sb = new StringBuilder(html.length());
148148

149149
final HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
150-
sb, new Handler<String>() {
150+
sb, new Handler<>() {
151151

152152
public void handle(String x) {
153153
throw new AssertionError(x);

src/test/java/org/owasp/html/HtmlChangeReporterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static final void testChangeReporting() {
4747
final StringBuilder log = new StringBuilder();
4848
HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
4949
out, Handler.DO_NOTHING);
50-
HtmlChangeListener<Context> listener = new HtmlChangeListener<Context>() {
50+
HtmlChangeListener<Context> listener = new HtmlChangeListener<>() {
5151
public void discardedTag(Context context, String elementName) {
5252
assertSame(testContext, context);
5353
log.append('<').append(elementName).append("> ");
@@ -63,7 +63,7 @@ public void discardedAttributes(
6363
log.append("> ");
6464
}
6565
};
66-
HtmlChangeReporter<Context> hcr = new HtmlChangeReporter<Context>(
66+
HtmlChangeReporter<Context> hcr = new HtmlChangeReporter<>(
6767
renderer, listener, testContext);
6868

6969
hcr.setPolicy(Sanitizers.FORMATTING.apply(hcr.getWrappedRenderer()));

src/test/java/org/owasp/html/HtmlSanitizerFuzzerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ public final void testFuzzHtmlParser() throws Exception {
7171
char[] fuzzyHtml1 = new char[length];
7272

7373
final LinkedBlockingQueue<Throwable> failures
74-
= new LinkedBlockingQueue<Throwable>();
74+
= new LinkedBlockingQueue<>();
7575

7676
final int runCount = 1000;
7777
// Use an executor so that any infinite loops do not cause the test runner
7878
// to fail.
7979
ThreadPoolExecutor executor = new ThreadPoolExecutor(
80-
10, 10, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
80+
10, 10, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
8181

8282
for (int run = runCount; --run >= 0;) {
8383
for (int i = length; --i >= 0;) { fuzzyHtml0[i] = html.charAt(i); }

src/test/java/org/owasp/html/IntVectorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void testIntVector() {
1515
Random r = new Random(0xA03B79241106C82FL);
1616

1717
IntVector iv = new IntVector();
18-
LinkedList<Integer> ad = new LinkedList<Integer>();
18+
LinkedList<Integer> ad = new LinkedList<>();
1919

2020
for (int i = 0; i < 200000; ++i) {
2121
switch (r.nextInt(4)) {

src/test/java/org/owasp/html/PolicyFactoryTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static void testAnd() {
123123
final StringBuilder out = new StringBuilder();
124124

125125
// A noisy listener that logs.
126-
HtmlChangeListener<Object> listener = new HtmlChangeListener<Object>() {
126+
HtmlChangeListener<Object> listener = new HtmlChangeListener<>() {
127127

128128
public void discardedTag(Object ctx, String elementName) {
129129
assertEquals(context, ctx);
@@ -141,7 +141,7 @@ public void discardedAttributes(
141141

142142
};
143143

144-
Handler<IOException> ioHandler = new Handler<IOException>() {
144+
Handler<IOException> ioHandler = new Handler<>() {
145145

146146
public void handle(IOException x) {
147147
log.append("Handled IOException " + x.getMessage() + "\n");
@@ -150,7 +150,7 @@ public void handle(IOException x) {
150150
};
151151

152152
// Should not be called.
153-
Handler<String> badHtmlHandler = new Handler<String>() {
153+
Handler<String> badHtmlHandler = new Handler<>() {
154154

155155
public void handle(String x) {
156156
throw new AssertionError(x);
@@ -611,7 +611,7 @@ static final class SubstringFilter implements AttributePolicy {
611611

612612
public String apply(
613613
String elementName, String attributeName, String value) {
614-
List<String> outParts = new ArrayList<String>();
614+
List<String> outParts = new ArrayList<>();
615615
for (String part : value.split(",")) {
616616
part = part.trim();
617617
if (part.contains(substr)) {

src/test/java/org/owasp/html/SanitizersTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public static final void testAndOrdering() {
382382
+ "<img src=\"http://example.org\" />oogle</a>";
383383

384384
for (List<PolicyFactory> permutation :
385-
new Permutations<PolicyFactory>(
385+
new Permutations<>(
386386
Sanitizers.BLOCKS,
387387
Sanitizers.IMAGES,
388388
Sanitizers.STYLES,
@@ -584,7 +584,7 @@ private static class Permutations<T> implements Iterable<List<T>> {
584584
}
585585

586586
public Iterator<List<T>> iterator() {
587-
return new Iterator<List<T>>() {
587+
return new Iterator<>() {
588588
private int i;
589589
private final int limit;
590590
private final BitSet mask;

0 commit comments

Comments
 (0)