From: Stephen Kitt Date: Thu, 22 Sep 2016 15:08:38 +0000 (+0200) Subject: Mechanical code cleanup (commons) X-Git-Tag: release/carbon~465 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=d6a49e6efc758716d8f22e5b88509c21468c174a Mechanical code cleanup (commons) * Remove unnecessary type specifiers (use Java 7 <>) * Remove unnecessary "extends Object" declarations * Remove unnecessary semi-colons * Merge identical catch blocks * Remove redundant modifiers: - enum constructors are private by default - interface properties are public static final by default - interface methods are public abstract by default - interfaces are abstract by default - inner interfaces are static by default - inner classes in interfaces are public static by default Change-Id: If1805b63e52c1ab0c68983e7856e7ccf184cb2a9 Signed-off-by: Stephen Kitt --- diff --git a/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/EtherTypes.java b/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/EtherTypes.java index e3c46fbf6a..de5834faee 100644 --- a/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/EtherTypes.java +++ b/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/EtherTypes.java @@ -32,7 +32,7 @@ public enum EtherTypes { private String description; private int number; - private EtherTypes(String description, int number) { + EtherTypes(String description, int number) { this.description = description; this.number = number; } @@ -95,7 +95,7 @@ public enum EtherTypes { } public static List getEtherTypesNameList() { - List ethertypesList = new ArrayList(); + List ethertypesList = new ArrayList<>(); for (EtherTypes type : EtherTypes.values()) { ethertypesList.add(type.toString()); } diff --git a/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/Ethernet.java b/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/Ethernet.java index ea861e00ca..c2d9e7003e 100644 --- a/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/Ethernet.java +++ b/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/Ethernet.java @@ -27,15 +27,15 @@ public class Ethernet extends Packet { // to add new coming packet classes public static final Map> etherTypeClassMap; static { - etherTypeClassMap = new HashMap>(); + etherTypeClassMap = new HashMap<>(); etherTypeClassMap.put(EtherTypes.LLDP.shortValue(), LLDP.class); } private static Map> fieldCoordinates = new LinkedHashMap>() { private static final long serialVersionUID = 1L; { - put(DMAC, new ImmutablePair(0, 48)); - put(SMAC, new ImmutablePair(48, 48)); - put(ETHT, new ImmutablePair(96, 16)); + put(DMAC, new ImmutablePair<>(0, 48)); + put(SMAC, new ImmutablePair<>(48, 48)); + put(ETHT, new ImmutablePair<>(96, 16)); } }; private final Map fieldValues; @@ -45,7 +45,7 @@ public class Ethernet extends Packet { */ public Ethernet() { super(); - fieldValues = new HashMap(); + fieldValues = new HashMap<>(); hdrFieldCoordMap = fieldCoordinates; hdrFieldsMap = fieldValues; } @@ -56,7 +56,7 @@ public class Ethernet extends Packet { */ public Ethernet(boolean writeAccess) { super(writeAccess); - fieldValues = new HashMap(); + fieldValues = new HashMap<>(); hdrFieldCoordMap = fieldCoordinates; hdrFieldsMap = fieldValues; } diff --git a/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/LLDPTLV.java b/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/LLDPTLV.java index 7b93d5f19c..3c5623475e 100644 --- a/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/LLDPTLV.java +++ b/opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/LLDPTLV.java @@ -57,7 +57,7 @@ public class LLDPTLV extends Packet { private byte value; - private TLVType(byte value) { + TLVType(byte value) { this.value = value; } @@ -70,9 +70,9 @@ public class LLDPTLV extends Packet { private static final long serialVersionUID = 1L; { - put(TYPE, new MutablePair(0, 7)); - put(LENGTH, new MutablePair(7, 9)); - put(VALUE, new MutablePair(16, 0)); + put(TYPE, new MutablePair<>(0, 7)); + put(LENGTH, new MutablePair<>(7, 9)); + put(VALUE, new MutablePair<>(16, 0)); } }; @@ -84,7 +84,7 @@ public class LLDPTLV extends Packet { */ public LLDPTLV() { payload = null; - fieldValues = new HashMap(LLDPTLVFields); + fieldValues = new HashMap<>(LLDPTLVFields); hdrFieldCoordMap = fieldCoordinates; hdrFieldsMap = fieldValues; } diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java index 0aae75dedd..334ccc2cc3 100644 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java +++ b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java @@ -103,7 +103,7 @@ public abstract class AbstractDispatcher, L extends @Override protected void initChannel(final CH ch) { - initializer.initializeChannel(ch, new DefaultPromise(executor)); + initializer.initializeChannel(ch, new DefaultPromise<>(executor)); } }); diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java index 6c4af0186f..331e94949e 100644 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java +++ b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java @@ -277,7 +277,7 @@ public class ServerTest { } }; } - }, new DefaultPromise(GlobalEventExecutor.INSTANCE), eventLoopGroup); + }, new DefaultPromise<>(GlobalEventExecutor.INSTANCE), eventLoopGroup); final ReconnectStrategyFactory reconnectStrategyFactory = mock(ReconnectStrategyFactory.class); final ReconnectStrategy reconnectStrategy = getMockedReconnectStrategy(); @@ -303,7 +303,7 @@ public class ServerTest { final Channel channel, final Promise promise) { return new SimpleSessionNegotiator(promise, channel); } - }, new DefaultPromise(GlobalEventExecutor.INSTANCE), eventLoopGroup); + }, new DefaultPromise<>(GlobalEventExecutor.INSTANCE), eventLoopGroup); } private ReconnectStrategy getMockedReconnectStrategy() throws Exception { diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java index 7004ee6141..5d167566f2 100644 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java +++ b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; public class SimpleSessionListener implements SessionListener { private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class); - public List messages = new ArrayList(); + public List messages = new ArrayList<>(); public boolean up = false;