Sfoglia il codice sorgente

Java 7 conversions

Change-Id: Ib05f625f14ab2f486f0c83c47c860dd0f0ef3ba1
Reviewed-on: http://gerrit.dmdirc.com/2896
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/96/2896/3
Greg Holmes 10 anni fa
parent
commit
779a61d876

+ 1
- 1
src/com/dmdirc/util/CommandUtils.java Vedi File

@@ -44,7 +44,7 @@ public final class CommandUtils {
44 44
      * @return An array of arguments corresponding to the command
45 45
      */
46 46
     public static String[] parseArguments(final String command) {
47
-        final List<String> args = new ArrayList<String>();
47
+        final List<String> args = new ArrayList<>();
48 48
         final StringBuilder builder = new StringBuilder();
49 49
         boolean inquote = false;
50 50
 

+ 3
- 14
src/com/dmdirc/util/SimpleInjector.java Vedi File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.util;
24 24
 
25 25
 import java.lang.reflect.Constructor;
26
-import java.lang.reflect.InvocationTargetException;
27 26
 import java.util.HashMap;
28 27
 import java.util.Map;
29 28
 
@@ -40,8 +39,7 @@ public class SimpleInjector {
40 39
     private final SimpleInjector[] parents;
41 40
 
42 41
     /** A mapping of known classes to the objects that should be injected. */
43
-    private final Map<Class<?>, Object> parameters
44
-            = new HashMap<Class<?>, Object>();
42
+    private final Map<Class<?>, Object> parameters = new HashMap<>();
45 43
 
46 44
     /**
47 45
      * Creates a new injector which will inherit injection parameters from
@@ -97,8 +95,7 @@ public class SimpleInjector {
97 95
      * @return A map of injectable parameters
98 96
      */
99 97
     public Map<Class<?>, Object> getParameters() {
100
-        final Map<Class<?>, Object> localParams
101
-                = new HashMap<Class<?>, Object>(parameters.size());
98
+        final Map<Class<?>, Object> localParams = new HashMap<>(parameters.size());
102 99
 
103 100
         for (SimpleInjector parent : parents) {
104 101
             localParams.putAll(parent.getParameters());
@@ -146,16 +143,8 @@ public class SimpleInjector {
146 143
             if (i == args.length) {
147 144
                 try {
148 145
                     return ctor.newInstance(args);
149
-                } catch (IllegalAccessException ex) {
146
+                } catch (ReflectiveOperationException ex) {
150 147
                     throwable = ex;
151
-                } catch (IllegalArgumentException ex) {
152
-                    throwable = ex;
153
-                } catch (InstantiationException ex) {
154
-                    throwable = ex;
155
-                } catch (InvocationTargetException ex) {
156
-                    throwable = ex;
157
-                } catch (LinkageError err) {
158
-                    throwable = err;
159 148
                 }
160 149
             }
161 150
         }

+ 6
- 6
src/com/dmdirc/util/collections/DoubleMap.java Vedi File

@@ -41,9 +41,9 @@ import java.util.Set;
41 41
 public class DoubleMap<A,B> implements Map<A, B> {
42 42
 
43 43
     /** The keys in this map. */
44
-    protected final List<A> keys = new ArrayList<A>();
44
+    protected final List<A> keys = new ArrayList<>();
45 45
     /** The values in this map. */
46
-    protected final List<B> values = new ArrayList<B>();
46
+    protected final List<B> values = new ArrayList<>();
47 47
 
48 48
     /**
49 49
      * Retrieves the value associated with the specified key.
@@ -87,7 +87,7 @@ public class DoubleMap<A,B> implements Map<A, B> {
87 87
     /** {@inheritDoc} */
88 88
     @Override
89 89
     public Set<A> keySet() {
90
-        return new HashSet<A>(keys);
90
+        return new HashSet<>(keys);
91 91
     }
92 92
 
93 93
     /** {@inheritDoc} */
@@ -152,15 +152,15 @@ public class DoubleMap<A,B> implements Map<A, B> {
152 152
     /** {@inheritDoc} */
153 153
     @Override
154 154
     public Collection<B> values() {
155
-        return new ArrayList<B>(values);
155
+        return new ArrayList<>(values);
156 156
     }
157 157
 
158 158
     /** {@inheritDoc} */
159 159
     @Override
160 160
     public Set<Entry<A, B>> entrySet() {
161
-        final Set<Entry<A, B>> set = new HashSet<Entry<A, B>>();
161
+        final Set<Entry<A, B>> set = new HashSet<>();
162 162
         for (A key : keys) {
163
-            set.add(new SimpleEntry<A, B>(key, getValue(key)));
163
+            set.add(new SimpleEntry<>(key, getValue(key)));
164 164
         }
165 165
         return set;
166 166
     }

+ 2
- 2
src/com/dmdirc/util/collections/MapList.java Vedi File

@@ -55,7 +55,7 @@ public class MapList<S, T> {
55 55
      * Creates a new, empty MapList.
56 56
      */
57 57
     public MapList() {
58
-        map = new HashMap<S, List<T>>();
58
+        map = new HashMap<>();
59 59
     }
60 60
 
61 61
     /**
@@ -255,7 +255,7 @@ public class MapList<S, T> {
255 255
      * @return This MapList's map.
256 256
      */
257 257
     public Map<S, List<T>> getMap() {
258
-        return new HashMap<S, List<T>>(map);
258
+        return new HashMap<>(map);
259 259
     }
260 260
 
261 261
 }

+ 2
- 2
src/com/dmdirc/util/collections/RollingList.java Vedi File

@@ -33,7 +33,7 @@ import java.util.List;
33 33
 public class RollingList<T> {
34 34
 
35 35
     /** The items in this rolling list. */
36
-    private final List<T> items = new ArrayList<T>();
36
+    private final List<T> items = new ArrayList<>();
37 37
     /** The maximum capacity of this list. */
38 38
     private final int capacity;
39 39
     /** Whether or not to add a fake empty item to the end of this list. */
@@ -212,6 +212,6 @@ public class RollingList<T> {
212 212
      * @return A list of items in this rolling list.
213 213
      */
214 214
     public List<T> getList() {
215
-        return new ArrayList<T>(items);
215
+        return new ArrayList<>(items);
216 216
     }
217 217
 }

+ 6
- 8
src/com/dmdirc/util/collections/WeakList.java Vedi File

@@ -38,8 +38,7 @@ import java.util.ListIterator;
38 38
 public class WeakList<T> implements List<T> {
39 39
 
40 40
     /** The items in this list. */
41
-    private final List<WeakReference<T>> list
42
-            = new ArrayList<WeakReference<T>>();
41
+    private final List<WeakReference<T>> list = new ArrayList<>();
43 42
 
44 43
     /**
45 44
      * Removes any entries from the list that have been GC'd.
@@ -59,7 +58,7 @@ public class WeakList<T> implements List<T> {
59 58
      * @return A list containing the items referenced by the specified list
60 59
      */
61 60
     private List<T> dereferenceList(final List<WeakReference<T>> list) {
62
-        final List<T> res = new ArrayList<T>();
61
+        final List<T> res = new ArrayList<>();
63 62
 
64 63
         for (WeakReference<T> item : list) {
65 64
             if (item.get() != null) {
@@ -81,8 +80,7 @@ public class WeakList<T> implements List<T> {
81 80
     @SuppressWarnings({"unchecked", "rawtypes"})
82 81
     private Collection<WeakReference<T>> referenceCollection(
83 82
             final Collection<?> c) {
84
-        final Collection<WeakReference<T>> res
85
-                = new ArrayList<WeakReference<T>>();
83
+        final Collection<WeakReference<T>> res = new ArrayList<>();
86 84
 
87 85
         for (Object item : c) {
88 86
             res.add(new EquatableWeakReference(item));
@@ -135,7 +133,7 @@ public class WeakList<T> implements List<T> {
135 133
     /** {@inheritDoc} */
136 134
     @Override
137 135
     public boolean add(final T e) {
138
-        return list.add(new EquatableWeakReference<T>(e));
136
+        return list.add(new EquatableWeakReference<>(e));
139 137
     }
140 138
 
141 139
     /** {@inheritDoc} */
@@ -192,7 +190,7 @@ public class WeakList<T> implements List<T> {
192 190
     /** {@inheritDoc} */
193 191
     @Override
194 192
     public T set(final int index, final T element) {
195
-        list.set(index, new EquatableWeakReference<T>(element));
193
+        list.set(index, new EquatableWeakReference<>(element));
196 194
 
197 195
         return element;
198 196
     }
@@ -200,7 +198,7 @@ public class WeakList<T> implements List<T> {
200 198
     /** {@inheritDoc} */
201 199
     @Override
202 200
     public void add(final int index, final T element) {
203
-        list.add(index, new EquatableWeakReference<T>(element));
201
+        list.add(index, new EquatableWeakReference<>(element));
204 202
     }
205 203
 
206 204
     /** {@inheritDoc} */

+ 5
- 6
src/com/dmdirc/util/io/ConfigFile.java Vedi File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.util.io;
24 24
 
25 25
 import com.dmdirc.util.collections.MapList;
26
+
26 27
 import java.io.File;
27 28
 import java.io.IOException;
28 29
 import java.io.InputStream;
@@ -39,15 +40,13 @@ import java.util.Map;
39 40
 public class ConfigFile extends TextFile {
40 41
 
41 42
     /** A list of domains in this config file. */
42
-    private final List<String> domains = new ArrayList<String>();
43
+    private final List<String> domains = new ArrayList<>();
43 44
 
44 45
     /** The values associated with each flat domain. */
45
-    private final MapList<String, String> flatdomains
46
-            = new MapList<String, String>();
46
+    private final MapList<String, String> flatdomains = new MapList<>();
47 47
 
48 48
     /** The key/value sets associated with each key domain. */
49
-    private final Map<String, Map<String, String>> keydomains
50
-            = new HashMap<String, Map<String, String>>();
49
+    private final Map<String, Map<String, String>> keydomains = new HashMap<>();
51 50
 
52 51
     /** Whether or not we should automatically create domains. */
53 52
     private boolean automake;
@@ -158,7 +157,7 @@ public class ConfigFile extends TextFile {
158 157
                     + "that isn't writable");
159 158
         }
160 159
 
161
-        final List<String> lines = new ArrayList<String>();
160
+        final List<String> lines = new ArrayList<>();
162 161
 
163 162
         lines.add("# This is a DMDirc configuration file.");
164 163
         lines.add("# Written on: " + new GregorianCalendar().getTime()

+ 1
- 1
src/com/dmdirc/util/io/Downloader.java Vedi File

@@ -71,7 +71,7 @@ public final class Downloader {
71 71
     public static List<String> getPage(final String url, final String postData)
72 72
             throws IOException {
73 73
 
74
-        final List<String> res = new ArrayList<String>();
74
+        final List<String> res = new ArrayList<>();
75 75
 
76 76
         final URLConnection urlConn = getConnection(url, postData);
77 77
 

+ 2
- 2
src/com/dmdirc/util/io/ReverseFileReader.java Vedi File

@@ -127,7 +127,7 @@ public class ReverseFileReader {
127 127
         }
128 128
         // Used to store result to output.
129 129
 
130
-        final ArrayList<Byte> line = new ArrayList<Byte>(seekLength);
130
+        final ArrayList<Byte> line = new ArrayList<>(seekLength);
131 131
         // Used to store position in file pre-read
132 132
         long fp = 0;
133 133
         // Used to store position in file when this is called
@@ -224,7 +224,7 @@ public class ReverseFileReader {
224 224
      * @return The requested lines
225 225
      */
226 226
     public Stack<String> getLines(final int numLines) {
227
-        final Stack<String> result = new Stack<String>();
227
+        final Stack<String> result = new Stack<>();
228 228
         for (int i = 0; i < numLines; ++i) {
229 229
             try {
230 230
                 result.push(getNextLine());

+ 1
- 1
src/com/dmdirc/util/io/TextFile.java Vedi File

@@ -133,7 +133,7 @@ public class TextFile {
133 133
             inputStream = file == null ? is : new FileInputStream(file);
134 134
             inputReader = new InputStreamReader(inputStream, charset);
135 135
             reader = new BufferedReader(inputReader);
136
-            lines = new ArrayList<String>();
136
+            lines = new ArrayList<>();
137 137
 
138 138
             String line;
139 139
 

+ 1
- 2
src/com/dmdirc/util/validators/ValidatorChain.java Vedi File

@@ -35,8 +35,7 @@ import java.util.List;
35 35
 public class ValidatorChain<A> implements Validator<A> {
36 36
 
37 37
     /** A list of validators to use. */
38
-    private final List<Validator<A>> validatorList
39
-            = new ArrayList<Validator<A>>();
38
+    private final List<Validator<A>> validatorList = new ArrayList<>();
40 39
 
41 40
     /**
42 41
      * Creates a new validator chain containing the specified validators.

+ 4
- 4
test/com/dmdirc/util/collections/DoubleMapTest.java Vedi File

@@ -30,7 +30,7 @@ public class DoubleMapTest {
30 30
 
31 31
     @Test
32 32
     public void testPut() {
33
-        final DoubleMap<String, String> dm = new DoubleMap<String, String>();
33
+        final DoubleMap<String, String> dm = new DoubleMap<>();
34 34
         dm.put("a", "b");
35 35
         
36 36
         assertEquals(1, dm.keySet().size());
@@ -41,19 +41,19 @@ public class DoubleMapTest {
41 41
     
42 42
     @Test(expected=NullPointerException.class)
43 43
     public void testPutNull1() {
44
-        final DoubleMap<String, String> dm = new DoubleMap<String, String>();
44
+        final DoubleMap<String, String> dm = new DoubleMap<>();
45 45
         dm.put(null, "b");
46 46
     }
47 47
     
48 48
     @Test(expected=NullPointerException.class)
49 49
     public void testPutNull2() {
50
-        final DoubleMap<String, String> dm = new DoubleMap<String, String>();
50
+        final DoubleMap<String, String> dm = new DoubleMap<>();
51 51
         dm.put("a", null);
52 52
     }    
53 53
     
54 54
     @Test
55 55
     public void testGet() {
56
-        final DoubleMap<String, String> dm = new DoubleMap<String, String>();
56
+        final DoubleMap<String, String> dm = new DoubleMap<>();
57 57
         dm.put("a", "b");
58 58
         dm.put("b", "c");
59 59
         dm.put("c", "a");

+ 3
- 3
test/com/dmdirc/util/collections/EquatableWeakReferenceTest.java Vedi File

@@ -32,8 +32,8 @@ public class EquatableWeakReferenceTest {
32 32
     @Test
33 33
     public void testEquals() {
34 34
         final Object myObject = "moo";
35
-        final Reference<Object> myRef = new WeakReference<Object>(myObject);
36
-        final EquatableWeakReference<Object> ewf = new EquatableWeakReference<Object>(myObject);
35
+        final Reference<Object> myRef = new WeakReference<>(myObject);
36
+        final EquatableWeakReference<Object> ewf = new EquatableWeakReference<>(myObject);
37 37
 
38 38
         assertTrue(ewf.equals(myObject));
39 39
         assertTrue(ewf.equals(myRef));
@@ -44,7 +44,7 @@ public class EquatableWeakReferenceTest {
44 44
     @Test
45 45
     public void testHashCode() {
46 46
         final Object myObject = "moo";
47
-        final EquatableWeakReference<Object> ewf = new EquatableWeakReference<Object>(myObject);
47
+        final EquatableWeakReference<Object> ewf = new EquatableWeakReference<>(myObject);
48 48
         
49 49
         assertEquals(myObject.hashCode(), ewf.hashCode());
50 50
     }

+ 15
- 15
test/com/dmdirc/util/collections/MapListTest.java Vedi File

@@ -33,7 +33,7 @@ public class MapListTest {
33 33
 
34 34
     @Test
35 35
     public void testIsEmpty() {
36
-        final MapList<String, String> test = new MapList<String, String>();
36
+        final MapList<String, String> test = new MapList<>();
37 37
         assertTrue(test.isEmpty());
38 38
 
39 39
         test.add("a", "b");
@@ -44,8 +44,8 @@ public class MapListTest {
44 44
 
45 45
     @Test
46 46
     public void testAddCollection() {
47
-        final MapList<String, String> test = new MapList<String, String>();
48
-        final List<String> testList = new ArrayList<String>();
47
+        final MapList<String, String> test = new MapList<>();
48
+        final List<String> testList = new ArrayList<>();
49 49
         testList.add("d");
50 50
         testList.add("e");
51 51
         test.add("key", testList);
@@ -57,7 +57,7 @@ public class MapListTest {
57 57
 
58 58
     @Test
59 59
     public void testClear() {
60
-        final MapList<String, String> test = new MapList<String, String>();
60
+        final MapList<String, String> test = new MapList<>();
61 61
         test.add("a", "b");
62 62
         test.add("d", "e");
63 63
         test.clear();
@@ -66,7 +66,7 @@ public class MapListTest {
66 66
 
67 67
     @Test
68 68
     public void testClearKey() {
69
-        final MapList<String, String> test = new MapList<String, String>();
69
+        final MapList<String, String> test = new MapList<>();
70 70
         test.add("a", "b");
71 71
         test.add("d", "e");
72 72
         test.clear("a");
@@ -76,7 +76,7 @@ public class MapListTest {
76 76
 
77 77
     @Test
78 78
     public void testRemove() {
79
-        final MapList<String, String> test = new MapList<String, String>();
79
+        final MapList<String, String> test = new MapList<>();
80 80
         test.add("a", "b");
81 81
         test.add("d", "e");
82 82
         test.remove("z", "b");
@@ -93,7 +93,7 @@ public class MapListTest {
93 93
 
94 94
     @Test
95 95
     public void testRemoveKey() {
96
-        final MapList<String, String> instance = new MapList<String, String>();
96
+        final MapList<String, String> instance = new MapList<>();
97 97
         instance.add("a", "b");
98 98
         assertTrue(instance.containsKey("a"));
99 99
         instance.remove("a");
@@ -102,7 +102,7 @@ public class MapListTest {
102 102
 
103 103
     @Test
104 104
     public void testKeySet() {
105
-        final MapList<String, String> test = new MapList<String, String>();
105
+        final MapList<String, String> test = new MapList<>();
106 106
         test.add("a", "b");
107 107
         test.add("d", "e");
108 108
         assertEquals(2, test.keySet().size());
@@ -112,21 +112,21 @@ public class MapListTest {
112 112
 
113 113
     @Test
114 114
     public void testContainsKey() {
115
-        final MapList<String, String> test = new MapList<String, String>();
115
+        final MapList<String, String> test = new MapList<>();
116 116
         test.add("a", "b");
117 117
         assertTrue(test.containsKey("a"));
118 118
     }
119 119
 
120 120
     @Test
121 121
     public void testContainsValue() {
122
-        final MapList<String, String> test = new MapList<String, String>();
122
+        final MapList<String, String> test = new MapList<>();
123 123
         test.add("a", "b");
124 124
         assertTrue(test.containsValue("a", "b"));
125 125
     }
126 126
 
127 127
     @Test
128 128
     public void testGet() {
129
-        final MapList<String, String> test = new MapList<String, String>();
129
+        final MapList<String, String> test = new MapList<>();
130 130
         test.add("a", "b");
131 131
         assertEquals(1, test.get("a").size());
132 132
         assertEquals("b", test.get("a").get(0));
@@ -135,10 +135,10 @@ public class MapListTest {
135 135
 
136 136
     @Test
137 137
     public void testInherit() {
138
-        final MapList<String, String> test1 = new MapList<String, String>();
138
+        final MapList<String, String> test1 = new MapList<>();
139 139
         test1.add("a", "b");
140 140
 
141
-        final MapList<String, String> test2 = new MapList<String, String>(test1);
141
+        final MapList<String, String> test2 = new MapList<>(test1);
142 142
         assertEquals(1, test2.get("a").size());
143 143
         assertEquals("b", test2.get("a").get(0));
144 144
         assertEquals("b", test2.get("a", 0));
@@ -146,11 +146,11 @@ public class MapListTest {
146 146
 
147 147
     @Test
148 148
     public void testGetMap() {
149
-        final MapList<String, String> test1 = new MapList<String, String>();
149
+        final MapList<String, String> test1 = new MapList<>();
150 150
         test1.add("a", "b");
151 151
         assertNotSame(test1.getMap(), test1.getMap());
152 152
 
153
-        final MapList<String, String> test2 = new MapList<String, String>(test1);
153
+        final MapList<String, String> test2 = new MapList<>(test1);
154 154
         assertEquals(test1.getMap(), test2.getMap());
155 155
     }
156 156
 

+ 2
- 2
test/com/dmdirc/util/collections/ObservableListDecoratorTest.java Vedi File

@@ -41,8 +41,8 @@ public class ObservableListDecoratorTest {
41 41
 
42 42
     @Before
43 43
     public void setup() {
44
-        list = new LinkedList<String>();
45
-        obslist = new ObservableListDecorator<String>(list);
44
+        list = new LinkedList<>();
45
+        obslist = new ObservableListDecorator<>(list);
46 46
         observer = mock(ListObserver.class);
47 47
         obslist.addListListener(observer);
48 48
     }

+ 7
- 7
test/com/dmdirc/util/collections/RollingListTest.java Vedi File

@@ -30,7 +30,7 @@ public class RollingListTest {
30 30
 
31 31
     @Test
32 32
     public void testIsEmpty() {
33
-        final RollingList<String> rl = new RollingList<String>(1);
33
+        final RollingList<String> rl = new RollingList<>(1);
34 34
         assertTrue(rl.isEmpty());
35 35
         assertTrue(rl.getList().isEmpty());
36 36
         
@@ -41,7 +41,7 @@ public class RollingListTest {
41 41
     
42 42
     @Test
43 43
     public void testRolling() {
44
-        final RollingList<String> rl = new RollingList<String>(1);
44
+        final RollingList<String> rl = new RollingList<>(1);
45 45
         
46 46
         rl.add("Foo");
47 47
         rl.add("Bar");
@@ -54,7 +54,7 @@ public class RollingListTest {
54 54
     
55 55
     @Test
56 56
     public void testClear() {
57
-        final RollingList<String> rl = new RollingList<String>(3);
57
+        final RollingList<String> rl = new RollingList<>(3);
58 58
         
59 59
         rl.add("Foo");
60 60
         rl.add("Bar");
@@ -67,7 +67,7 @@ public class RollingListTest {
67 67
     
68 68
     @Test
69 69
     public void testPositions() {
70
-        final RollingList<String> rl = new RollingList<String>(3);
70
+        final RollingList<String> rl = new RollingList<>(3);
71 71
         
72 72
         rl.add("Foo");
73 73
         rl.add("Bar");
@@ -84,7 +84,7 @@ public class RollingListTest {
84 84
 
85 85
     @Test
86 86
     public void testSetPosition() {
87
-        final RollingList<String> rl = new RollingList<String>(3);
87
+        final RollingList<String> rl = new RollingList<>(3);
88 88
 
89 89
         rl.add("Foo");
90 90
         rl.add("Bar");
@@ -103,7 +103,7 @@ public class RollingListTest {
103 103
     
104 104
     @Test
105 105
     public void testPrevNext() {
106
-        final RollingList<String> rl = new RollingList<String>(3);
106
+        final RollingList<String> rl = new RollingList<>(3);
107 107
         
108 108
         rl.add("Foo");
109 109
         rl.add("Bar");
@@ -122,7 +122,7 @@ public class RollingListTest {
122 122
     
123 123
     @Test
124 124
     public void testEmpty() {
125
-        final RollingList<String> rl = new RollingList<String>(1, "Meep");
125
+        final RollingList<String> rl = new RollingList<>(1, "Meep");
126 126
         rl.add("Foo");
127 127
         
128 128
         assertEquals("Meep", rl.getNext());

+ 26
- 26
test/com/dmdirc/util/collections/WeakListTest.java Vedi File

@@ -35,7 +35,7 @@ public class WeakListTest {
35 35
 
36 36
     @Test
37 37
     public void testIsEmpty() {
38
-        final WeakList<String> instance = new WeakList<String>();
38
+        final WeakList<String> instance = new WeakList<>();
39 39
         assertTrue(instance.isEmpty());
40 40
         instance.add("test1");
41 41
         assertFalse(instance.isEmpty());
@@ -43,14 +43,14 @@ public class WeakListTest {
43 43
 
44 44
     @Test
45 45
     public void testAdd() {
46
-        final WeakList<String> instance = new WeakList<String>();
46
+        final WeakList<String> instance = new WeakList<>();
47 47
         assertTrue(instance.add("test1"));
48 48
         assertFalse(instance.isEmpty());
49 49
     }
50 50
 
51 51
     @Test
52 52
     public void testAdd_Int() {
53
-        final WeakList<String> instance = new WeakList<String>();
53
+        final WeakList<String> instance = new WeakList<>();
54 54
         assertTrue(instance.add("test1"));
55 55
         instance.add(0, "test2");
56 56
         assertEquals("test2", instance.get(0));
@@ -58,7 +58,7 @@ public class WeakListTest {
58 58
 
59 59
     @Test
60 60
     public void testRemove() {
61
-        final WeakList<String> instance = new WeakList<String>();
61
+        final WeakList<String> instance = new WeakList<>();
62 62
         instance.add("test1");
63 63
         assertFalse(instance.isEmpty());
64 64
         assertTrue(instance.remove("test1"));
@@ -67,7 +67,7 @@ public class WeakListTest {
67 67
 
68 68
     @Test
69 69
     public void testRemove_Int() {
70
-        final WeakList<String> instance = new WeakList<String>();
70
+        final WeakList<String> instance = new WeakList<>();
71 71
         assertTrue(instance.isEmpty());
72 72
         instance.add("test1");
73 73
         instance.add("test2");
@@ -79,7 +79,7 @@ public class WeakListTest {
79 79
 
80 80
     @Test
81 81
     public void testGet() {
82
-        final WeakList<String> instance = new WeakList<String>();
82
+        final WeakList<String> instance = new WeakList<>();
83 83
         instance.add("test1");
84 84
         instance.add("test2");
85 85
         assertEquals("test1", instance.get(0));
@@ -88,7 +88,7 @@ public class WeakListTest {
88 88
 
89 89
     @Test
90 90
     public void testContains() {
91
-        final WeakList<String> instance = new WeakList<String>();
91
+        final WeakList<String> instance = new WeakList<>();
92 92
         assertFalse(instance.contains("test1"));
93 93
         instance.add("test1");
94 94
         assertTrue(instance.contains("test1"));
@@ -99,7 +99,7 @@ public class WeakListTest {
99 99
      */
100 100
     @Test
101 101
     public void testToArray_0args() {
102
-        final WeakList<String> instance = new WeakList<String>();
102
+        final WeakList<String> instance = new WeakList<>();
103 103
         assertEquals(0, instance.toArray().length);
104 104
         instance.add("test1");
105 105
         instance.add("test2");
@@ -114,7 +114,7 @@ public class WeakListTest {
114 114
      */
115 115
     @Test
116 116
     public void testToArray_GenericType() {
117
-        final WeakList<String> instance = new WeakList<String>();
117
+        final WeakList<String> instance = new WeakList<>();
118 118
         assertEquals(0, instance.toArray(new String[0]).length);
119 119
         instance.add("test1");
120 120
         instance.add("test2");
@@ -129,10 +129,10 @@ public class WeakListTest {
129 129
      */
130 130
     @Test
131 131
     public void testContainsAllAddAll() {
132
-        final List<String> list = new ArrayList<String>();
132
+        final List<String> list = new ArrayList<>();
133 133
         list.add("test1");
134 134
         list.add("test2");
135
-        final WeakList<String> instance = new WeakList<String>();
135
+        final WeakList<String> instance = new WeakList<>();
136 136
         assertFalse(instance.containsAll(list));
137 137
         instance.addAll(list);
138 138
         assertTrue(instance.contains("test1"));
@@ -142,10 +142,10 @@ public class WeakListTest {
142 142
 
143 143
     @Test
144 144
     public void testAddAll_int_Collection() {
145
-        final List<String> list = new ArrayList<String>();
145
+        final List<String> list = new ArrayList<>();
146 146
         list.add("test1");
147 147
         list.add("test2");
148
-        final WeakList<String> instance = new WeakList<String>();
148
+        final WeakList<String> instance = new WeakList<>();
149 149
         instance.add("test3");
150 150
         System.out.println(instance);
151 151
         assertEquals("test3", instance.get(0));
@@ -159,7 +159,7 @@ public class WeakListTest {
159 159
     public void testIndexOf() {
160 160
         final String one = "test1";
161 161
         final String two = "test2";
162
-        final WeakList<String> instance = new WeakList<String>();
162
+        final WeakList<String> instance = new WeakList<>();
163 163
         instance.add(one);
164 164
         instance.add(two);
165 165
         assertEquals(2, instance.size());
@@ -171,7 +171,7 @@ public class WeakListTest {
171 171
     public void testLastIndexOf() {
172 172
         final String one = "test1";
173 173
         final String two = "test2";
174
-        final WeakList<String> instance = new WeakList<String>();
174
+        final WeakList<String> instance = new WeakList<>();
175 175
         instance.add(one);
176 176
         instance.add(two);
177 177
         instance.add(one);
@@ -181,10 +181,10 @@ public class WeakListTest {
181 181
 
182 182
     @Test
183 183
     public void testRemoveAll() {
184
-        final List<String> list = new ArrayList<String>();
184
+        final List<String> list = new ArrayList<>();
185 185
         list.add("test1");
186 186
         list.add("test2");
187
-        final WeakList<String> instance = new WeakList<String>();
187
+        final WeakList<String> instance = new WeakList<>();
188 188
         instance.addAll(list);
189 189
         assertFalse(instance.isEmpty());
190 190
         instance.removeAll(list);
@@ -193,10 +193,10 @@ public class WeakListTest {
193 193
 
194 194
     @Test
195 195
     public void testRetainAll() {
196
-        final List<String> list = new ArrayList<String>();
196
+        final List<String> list = new ArrayList<>();
197 197
         list.add("test1");
198 198
         list.add("test2");
199
-        final WeakList<String> instance = new WeakList<String>();
199
+        final WeakList<String> instance = new WeakList<>();
200 200
         instance.addAll(list);
201 201
         instance.add("test3");
202 202
         instance.add("test4");
@@ -207,10 +207,10 @@ public class WeakListTest {
207 207
 
208 208
     @Test
209 209
     public void testClear() {
210
-        final List<String> list = new ArrayList<String>();
210
+        final List<String> list = new ArrayList<>();
211 211
         list.add("test1");
212 212
         list.add("test2");
213
-        final WeakList<String> instance = new WeakList<String>();
213
+        final WeakList<String> instance = new WeakList<>();
214 214
         instance.addAll(list);
215 215
         assertFalse(instance.isEmpty());
216 216
         instance.clear();
@@ -219,7 +219,7 @@ public class WeakListTest {
219 219
 
220 220
     @Test
221 221
     public void testSet() {
222
-        final WeakList<String> instance = new WeakList<String>();
222
+        final WeakList<String> instance = new WeakList<>();
223 223
         instance.add("test1");
224 224
         assertEquals("test1", instance.get(0));
225 225
         instance.set(0, "test2");
@@ -228,7 +228,7 @@ public class WeakListTest {
228 228
 
229 229
     @Test
230 230
     public void testIterator() {
231
-        final WeakList<String> instance = new WeakList<String>();
231
+        final WeakList<String> instance = new WeakList<>();
232 232
         Iterator result = instance.iterator();
233 233
         assertFalse(result.hasNext());
234 234
         instance.add("test1");
@@ -241,7 +241,7 @@ public class WeakListTest {
241 241
 
242 242
     @Test
243 243
     public void testListIterator_0args() {
244
-        final WeakList<String> instance = new WeakList<String>();
244
+        final WeakList<String> instance = new WeakList<>();
245 245
         ListIterator result = instance.listIterator();
246 246
         assertFalse(result.hasNext());
247 247
         instance.add("test1");
@@ -254,7 +254,7 @@ public class WeakListTest {
254 254
 
255 255
     @Test(expected=IndexOutOfBoundsException.class)
256 256
     public void testListIterator_int() {
257
-        final WeakList<String> instance = new WeakList<String>();
257
+        final WeakList<String> instance = new WeakList<>();
258 258
         ListIterator result = instance.listIterator(1);
259 259
         assertFalse(result.hasNext());
260 260
         instance.add("test1");
@@ -269,7 +269,7 @@ public class WeakListTest {
269 269
 
270 270
     @Test
271 271
     public void testSubList() {
272
-        final WeakList<String> instance = new WeakList<String>();
272
+        final WeakList<String> instance = new WeakList<>();
273 273
         instance.add("test1");
274 274
         instance.add("test2");
275 275
         instance.add("test3");

+ 5
- 5
test/com/dmdirc/util/io/ConfigFileTest.java Vedi File

@@ -100,7 +100,7 @@ public class ConfigFileTest {
100 100
     public void testColons() throws IOException, InvalidConfigFileException {
101 101
         final File file = File.createTempFile("DMDirc.unittest", null);
102 102
         ConfigFile config = new ConfigFile(file);
103
-        Map<String, String> data = new HashMap<String, String>();
103
+        Map<String, String> data = new HashMap<>();
104 104
         data.put("test1", "hello");
105 105
         data.put("test:2", "hello");
106 106
         data.put("test3", "hello:");
@@ -121,7 +121,7 @@ public class ConfigFileTest {
121 121
     public void testEquals() throws IOException, InvalidConfigFileException {
122 122
         final File file = File.createTempFile("DMDirc.unittest", null);
123 123
         ConfigFile config = new ConfigFile(file);
124
-        Map<String, String> data = new HashMap<String, String>();
124
+        Map<String, String> data = new HashMap<>();
125 125
         data.put("test1", "hello");
126 126
         data.put("test=2", "hello");
127 127
         data.put("test3", "hello=");
@@ -142,7 +142,7 @@ public class ConfigFileTest {
142 142
     public void testNewlines() throws IOException, InvalidConfigFileException {
143 143
         final File file = File.createTempFile("DMDirc.unittest", null);
144 144
         ConfigFile config = new ConfigFile(file);
145
-        Map<String, String> data = new HashMap<String, String>();
145
+        Map<String, String> data = new HashMap<>();
146 146
         data.put("test1", "hello");
147 147
         data.put("test2", "hello\ngoodbye");
148 148
         data.put("test3", "hello\n");
@@ -165,7 +165,7 @@ public class ConfigFileTest {
165 165
     public void testBackslash() throws IOException, InvalidConfigFileException {
166 166
         final File file = File.createTempFile("DMDirc.unittest", null);
167 167
         ConfigFile config = new ConfigFile(file);
168
-        Map<String, String> data = new HashMap<String, String>();
168
+        Map<String, String> data = new HashMap<>();
169 169
         data.put("test1", "hello\\");
170 170
         data.put("test2", "\\nhello");
171 171
         data.put("test3\\", "hello");
@@ -186,7 +186,7 @@ public class ConfigFileTest {
186 186
     public void testHash() throws IOException, InvalidConfigFileException {
187 187
         final File file = File.createTempFile("DMDirc.unittest", null);
188 188
         ConfigFile config = new ConfigFile(file);
189
-        Map<String, String> data = new HashMap<String, String>();
189
+        Map<String, String> data = new HashMap<>();
190 190
         data.put("test1#", "hello");
191 191
         data.put("#test2", "hello");
192 192
         data.put("test3", "#hello");

+ 1
- 1
test/com/dmdirc/util/validators/OptionalValidatorTest.java Vedi File

@@ -29,7 +29,7 @@ public class OptionalValidatorTest {
29 29
 
30 30
     @Test
31 31
     public void testGetValidator() {
32
-        final Validator<String> validator = new PermissiveValidator<String>();
32
+        final Validator<String> validator = new PermissiveValidator<>();
33 33
         final OptionalValidator instance = new OptionalValidator(validator);
34 34
         assertEquals(validator, instance.getValidator());
35 35
     }

+ 1
- 1
test/com/dmdirc/util/validators/ValidatorChainTest.java Vedi File

@@ -33,7 +33,7 @@ public class ValidatorChainTest {
33 33
     @Test
34 34
     public void testValidate() {
35 35
         @SuppressWarnings("unchecked")
36
-        final ValidatorChain<String> chain = new ValidatorChain<String>(
36
+        final ValidatorChain<String> chain = new ValidatorChain<>(
37 37
                 new NotEmptyValidator(), new RegexStringValidator("[a-z]*", "abc"));
38 38
         
39 39
         assertTrue(chain.validate("").isFailure());

Loading…
Annulla
Salva