Improved: Remove redundant specification of type arguments
(OFBIZ-10937) Since Java 1.7, when defining generic types it is unnecessary to redefine those types in the constructor when it is done in the declared type. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857906 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -74,10 +74,10 @@ public class MiscTests extends GenericTestCaseBase {
|
||||
BigDecimal bigDecimal = new BigDecimal("1.234");
|
||||
URL url = new URL("http://ofbiz.apache.org");
|
||||
List<String> baseList = UtilMisc.toList("a", "1", "b", "2", "c", "3");
|
||||
List<String> arrayList = new ArrayList<String>();
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
arrayList.addAll(baseList);
|
||||
Map<String, String> baseMap = UtilMisc.toMap("a", "1", "b", "2", "c", "3");
|
||||
Map<String, String> hashMap = new HashMap<String, String>();
|
||||
Map<String, String> hashMap = new HashMap<>();
|
||||
hashMap.putAll(baseMap);
|
||||
Object[] testObjects = new Object[] {
|
||||
string,
|
||||
|
||||
+4
-4
@@ -44,7 +44,7 @@ public class TestJSONConverters extends TestCase {
|
||||
public void testJSONToMap() throws Exception {
|
||||
Converter<JSON, Map<String,String>> converter = UtilGenerics.cast(Converters.getConverter(JSON.class, Map.class));
|
||||
Map<String,String> map, convertedMap;
|
||||
map = new HashMap<String,String>();
|
||||
map = new HashMap<>();
|
||||
map.put("field1", "value1");
|
||||
JSON json = JSON.from(map);
|
||||
convertedMap = UtilGenerics.toMap(converter.convert(json));
|
||||
@@ -54,7 +54,7 @@ public class TestJSONConverters extends TestCase {
|
||||
public void testJSONToList() throws Exception {
|
||||
Converter<JSON, List<Object>> converter = UtilGenerics.cast(Converters.getConverter(JSON.class, List.class));
|
||||
List<Object> list, convertedList;
|
||||
list = new ArrayList<Object>();
|
||||
list = new ArrayList<>();
|
||||
list.add("field1");
|
||||
list.add("field2");
|
||||
JSON json = JSON.from(list);
|
||||
@@ -65,7 +65,7 @@ public class TestJSONConverters extends TestCase {
|
||||
public void testMapToJSON() throws Exception {
|
||||
Converter<Map<String,Object>, JSON> converter = UtilGenerics.cast(Converters.getConverter(Map.class, JSON.class));
|
||||
JSON json;
|
||||
Map<String,Object> map = new LinkedHashMap<String,Object>();
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("field1", "value1");
|
||||
map.put("field2", new BigDecimal("3.7"));
|
||||
json = converter.convert(map);
|
||||
@@ -75,7 +75,7 @@ public class TestJSONConverters extends TestCase {
|
||||
public void testListToJSON() throws Exception {
|
||||
Converter<List<String>, JSON> converter = UtilGenerics.cast(Converters.getConverter(List.class, JSON.class));
|
||||
JSON json;
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("field1");
|
||||
list.add("field2");
|
||||
json = converter.convert(list);
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class FlexibleLocation {
|
||||
private static final Map<String, LocationResolver> locationResolvers;
|
||||
|
||||
static {
|
||||
Map<String, LocationResolver> resolverMap = new HashMap<String, LocationResolver>(8);
|
||||
Map<String, LocationResolver> resolverMap = new HashMap<>(8);
|
||||
LocationResolver standardUrlResolver = new StandardUrlLocationResolver();
|
||||
resolverMap.put("http", standardUrlResolver);
|
||||
resolverMap.put("https", standardUrlResolver);
|
||||
|
||||
@@ -177,7 +177,7 @@ public final class UtilHttp {
|
||||
}
|
||||
|
||||
public static Map<String, Object> getMultiPartParameterMap(HttpServletRequest request) {
|
||||
Map<String, Object> multiPartMap = new HashMap<String, Object>();
|
||||
Map<String, Object> multiPartMap = new HashMap<>();
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
HttpSession session = request.getSession();
|
||||
boolean isMultiPart = ServletFileUpload.isMultipartContent(request);
|
||||
@@ -238,7 +238,7 @@ public final class UtilHttp {
|
||||
if (mapValue instanceof List<?>) {
|
||||
checkList(mapValue, Object.class).add(item.getString());
|
||||
} else if (mapValue instanceof String) {
|
||||
List<String> newList = new LinkedList<String>();
|
||||
List<String> newList = new LinkedList<>();
|
||||
newList.add((String) mapValue);
|
||||
newList.add(item.getString());
|
||||
multiPartMap.put(fieldName, newList);
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ public class FlexibleMapAccessorTests extends GenericTestCaseBase {
|
||||
}
|
||||
|
||||
private static <T> void fmaTest(String label, String getText, String putText, String fseText, Locale locale, T var, String value) {
|
||||
Map<String, Object> testMap = new HashMap<String, Object>();
|
||||
Map<String, Object> testMap = new HashMap<>();
|
||||
FlexibleMapAccessor<T> fmaGet = FlexibleMapAccessor.getInstance(getText);
|
||||
assertEquals(label + ":get-original-name", getText, fmaGet.getOriginalName());
|
||||
assertEquals(label + ":get-isEmpty", false, fmaGet.isEmpty());
|
||||
@@ -105,7 +105,7 @@ public class FlexibleMapAccessorTests extends GenericTestCaseBase {
|
||||
assertNotNull(label + ":put-null-map", caught);
|
||||
assertTrue(label + ":put-null-map-isEmpty", testMap.isEmpty());
|
||||
}
|
||||
Set<FlexibleMapAccessor<?>> set = new HashSet<FlexibleMapAccessor<?>>();
|
||||
Set<FlexibleMapAccessor<?>> set = new HashSet<>();
|
||||
assertFalse(label + ":not-in-set", set.contains(fmaGet));
|
||||
set.add(fmaGet);
|
||||
assertTrue(label + ":in-set", set.contains(fmaGet));
|
||||
@@ -114,7 +114,7 @@ public class FlexibleMapAccessorTests extends GenericTestCaseBase {
|
||||
private static void fmaEmptyTest(String label, String text) {
|
||||
FlexibleMapAccessor<Class<?>> fma = FlexibleMapAccessor.getInstance(text);
|
||||
assertTrue(label + ":isEmpty", fma.isEmpty());
|
||||
Map<String, Object> testMap = new HashMap<String, Object>();
|
||||
Map<String, Object> testMap = new HashMap<>();
|
||||
assertNull(label + ":get", fma.get(null));
|
||||
assertNull(label + ":get", fma.get(testMap));
|
||||
assertTrue(label + ":map-isEmpty-initial", testMap.isEmpty());
|
||||
@@ -173,7 +173,7 @@ public class FlexibleMapAccessorTests extends GenericTestCaseBase {
|
||||
boolean isVerbose = Debug.isOn(Debug.VERBOSE);
|
||||
try {
|
||||
Debug.set(Debug.VERBOSE, true);
|
||||
Map<String, Object> testMap = new CantRemoveMap<String, Object>();
|
||||
Map<String, Object> testMap = new CantRemoveMap<>();
|
||||
testMap.put("throwException", new ThrowException());
|
||||
assertNull("no var", FlexibleMapAccessor.getInstance("var").get(testMap));
|
||||
Object result = FlexibleMapAccessor.getInstance("throwException.value").get(testMap);
|
||||
|
||||
+7
-7
@@ -50,7 +50,7 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
"removeInternal-false",
|
||||
"size",
|
||||
};
|
||||
protected final Map<String, Integer> counts = new HashMap<String, Integer>();
|
||||
protected final Map<String, Integer> counts = new HashMap<>();
|
||||
protected final Map<K, V> proxyMap;
|
||||
|
||||
protected TestGenericMap() {
|
||||
@@ -62,9 +62,9 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
counts.put(countName, 0);
|
||||
}
|
||||
if (srcMap != null) {
|
||||
proxyMap = new HashMap<K, V>(srcMap);
|
||||
proxyMap = new HashMap<>(srcMap);
|
||||
} else {
|
||||
proxyMap = new HashMap<K, V>();
|
||||
proxyMap = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
}
|
||||
|
||||
public List<Integer> getCounts() {
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
List<Integer> result = new ArrayList<>();
|
||||
for (String countName: countNames) {
|
||||
result.add(counts.get(countName));
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
return new IteratorWrapper<Map.Entry<K, V>, Map.Entry<K, V>>(proxyMap.entrySet().iterator()) {
|
||||
@Override
|
||||
protected Map.Entry<K, V> convert(Map.Entry<K, V> src) {
|
||||
return new GenericMapEntry<K, V>(TestGenericMap.this, src.getKey(), noteAccess);
|
||||
return new GenericMapEntry<>(TestGenericMap.this, src.getKey(), noteAccess);
|
||||
}
|
||||
@Override
|
||||
protected void noteRemoval(Map.Entry<K, V> dest, Map.Entry<K, V> src) {
|
||||
@@ -150,7 +150,7 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
}
|
||||
|
||||
public void testFoo() throws Exception {
|
||||
TestGenericMap<String, Integer> map = new TestGenericMap<String, Integer>();
|
||||
TestGenericMap<String, Integer> map = new TestGenericMap<>();
|
||||
map.put("a", 0); Debug.logInfo("put a\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertEquals("get a", Integer.valueOf(0), map.get("a"));
|
||||
map.put("b", 1); Debug.logInfo("put b\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
@@ -167,7 +167,7 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
Debug.logInfo("map=" + map, module);
|
||||
Debug.logInfo("counts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
// this seems to call size()
|
||||
new HashMap<String, Integer>(map);
|
||||
new HashMap<>(map);
|
||||
Debug.logInfo("counts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -298,7 +298,7 @@ public abstract class FlexibleStringExpander implements Serializable, IsEmpty {
|
||||
return new FlexibleStringExpander[] { new ConstOffsetElem(chars, offset, length) };
|
||||
}
|
||||
int origLen = length;
|
||||
ArrayList<FlexibleStringExpander> strElems = new ArrayList<FlexibleStringExpander>();
|
||||
ArrayList<FlexibleStringExpander> strElems = new ArrayList<>();
|
||||
int currentInd = offset;
|
||||
int end = -1;
|
||||
while (start != -1) {
|
||||
@@ -652,7 +652,7 @@ public abstract class FlexibleStringExpander implements Serializable, IsEmpty {
|
||||
@Override
|
||||
protected Object get(Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
|
||||
try {
|
||||
Map <String, Object> contextCopy = new HashMap<String, Object>(context);
|
||||
Map <String, Object> contextCopy = new HashMap<>(context);
|
||||
Object obj = ScriptUtil.evaluate(this.language, this.script, this.parsedScript, contextCopy);
|
||||
if (obj != null) {
|
||||
return obj;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class NodeELResolver extends ELResolver {
|
||||
} else if (nodeList.getLength() == 1) {
|
||||
result = nodeList.item(0);
|
||||
} else {
|
||||
List<Node> newList = new ArrayList<Node>(nodeList.getLength());
|
||||
List<Node> newList = new ArrayList<>(nodeList.getLength());
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
newList.add(nodeList.item(i));
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AssertTests extends TestCase {
|
||||
} catch (IllegalArgumentException e) {}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
List<String> strList = new ArrayList<String>();
|
||||
List<String> strList = new ArrayList<>();
|
||||
try {
|
||||
Assert.notEmpty("foo", strList);
|
||||
fail("notEmpty(Collection) - IllegalArgumentException not thrown");
|
||||
@@ -97,7 +97,7 @@ public class AssertTests extends TestCase {
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
Map<String,String> strMap = new HashMap<String, String>();
|
||||
Map<String,String> strMap = new HashMap<>();
|
||||
try {
|
||||
Assert.notEmpty("foo", strMap);
|
||||
fail("notEmpty(Map) - IllegalArgumentException not thrown");
|
||||
|
||||
@@ -66,15 +66,15 @@ public class ObjectTypeTests extends GenericTestCaseBase {
|
||||
super(name);
|
||||
ntstmp = new Timestamp(781L);
|
||||
ntstmp.setNanos(123000000);
|
||||
list = new ArrayList<Object>();
|
||||
list = new ArrayList<>();
|
||||
list.add("one");
|
||||
list.add("two");
|
||||
list.add("three");
|
||||
map = new LinkedHashMap<String, Object>();
|
||||
map = new LinkedHashMap<>();
|
||||
map.put("one", "1");
|
||||
map.put("two", "2");
|
||||
map.put("three", "3");
|
||||
set = new LinkedHashSet<Object>(list);
|
||||
set = new LinkedHashSet<>(list);
|
||||
Calendar cal = UtilDateTime.getCalendarInstance(localeData.goodTimeZone, localeData.goodLocale);
|
||||
cal.set(1969, Calendar.DECEMBER, 31, 0, 0, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class ReferenceCleanerTests extends GenericTestCaseBase {
|
||||
|
||||
public void testReferenceCleaner() throws Exception {
|
||||
assertStaticHelperClass(ReferenceCleaner.class);
|
||||
final SynchronousQueue<String> queue = new SynchronousQueue<String>();
|
||||
final SynchronousQueue<String> queue = new SynchronousQueue<>();
|
||||
Object obj = new Object();
|
||||
ReferenceCleaner.Soft<Object> soft = new ReferenceCleaner.Soft<Object>(obj) {
|
||||
public void remove() throws Exception {
|
||||
@@ -53,7 +53,7 @@ public class ReferenceCleanerTests extends GenericTestCaseBase {
|
||||
queue.put("phantom");
|
||||
}
|
||||
};
|
||||
HashSet<String> foundEvents = new HashSet<String>();
|
||||
HashSet<String> foundEvents = new HashSet<>();
|
||||
useAllMemory();
|
||||
assertSame("still-soft", obj, soft.get());
|
||||
assertSame("still-weak", obj, weak.get());
|
||||
|
||||
@@ -200,7 +200,7 @@ public class StringUtilTests extends GenericTestCaseBase {
|
||||
}
|
||||
|
||||
public void testConvertChar() {
|
||||
Map<Character, Integer> conversions = new HashMap<Character, Integer>();
|
||||
Map<Character, Integer> conversions = new HashMap<>();
|
||||
conversions.put('0', 0); conversions.put('1', 1); conversions.put('2', 2); conversions.put('3', 3);
|
||||
conversions.put('4', 4); conversions.put('5', 5); conversions.put('6', 6); conversions.put('7', 7);
|
||||
conversions.put('8', 8); conversions.put('9', 9);
|
||||
|
||||
Reference in New Issue
Block a user