Mechanical code cleanup (commons) 65/46065/3
authorStephen Kitt <skitt@redhat.com>
Thu, 22 Sep 2016 15:08:38 +0000 (17:08 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 23 Sep 2016 18:48:37 +0000 (18:48 +0000)
* 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 <skitt@redhat.com>
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/EtherTypes.java
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/Ethernet.java
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/LLDPTLV.java
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ServerTest.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java

index e3c46fbf6a04a113a4f0e9f95245596065f9f4cc..de5834faee6a7988e9296f8b51f353b8160a4d53 100644 (file)
@@ -32,7 +32,7 @@ public enum EtherTypes {
     private String description;
     private int number;
 
     private String description;
     private int number;
 
-    private EtherTypes(String description, int number) {
+    EtherTypes(String description, int number) {
         this.description = description;
         this.number = number;
     }
         this.description = description;
         this.number = number;
     }
@@ -95,7 +95,7 @@ public enum EtherTypes {
     }
 
     public static List<String> getEtherTypesNameList() {
     }
 
     public static List<String> getEtherTypesNameList() {
-        List<String> ethertypesList = new ArrayList<String>();
+        List<String> ethertypesList = new ArrayList<>();
         for (EtherTypes type : EtherTypes.values()) {
             ethertypesList.add(type.toString());
         }
         for (EtherTypes type : EtherTypes.values()) {
             ethertypesList.add(type.toString());
         }
index ea861e00cafec4bf4fce2241043331003ba9a913..c2d9e7003e2908f23874e1495149bd14ffead437 100644 (file)
@@ -27,15 +27,15 @@ public class Ethernet extends Packet {
     // to add new coming packet classes
     public static final Map<Short, Class<? extends Packet>> etherTypeClassMap;
     static {
     // to add new coming packet classes
     public static final Map<Short, Class<? extends Packet>> etherTypeClassMap;
     static {
-        etherTypeClassMap = new HashMap<Short, Class<? extends Packet>>();
+        etherTypeClassMap = new HashMap<>();
         etherTypeClassMap.put(EtherTypes.LLDP.shortValue(), LLDP.class);
     }
     private static Map<String, Pair<Integer, Integer>> fieldCoordinates = new LinkedHashMap<String, Pair<Integer, Integer>>() {
         private static final long serialVersionUID = 1L;
         {
         etherTypeClassMap.put(EtherTypes.LLDP.shortValue(), LLDP.class);
     }
     private static Map<String, Pair<Integer, Integer>> fieldCoordinates = new LinkedHashMap<String, Pair<Integer, Integer>>() {
         private static final long serialVersionUID = 1L;
         {
-            put(DMAC, new ImmutablePair<Integer, Integer>(0, 48));
-            put(SMAC, new ImmutablePair<Integer, Integer>(48, 48));
-            put(ETHT, new ImmutablePair<Integer, Integer>(96, 16));
+            put(DMAC, new ImmutablePair<>(0, 48));
+            put(SMAC, new ImmutablePair<>(48, 48));
+            put(ETHT, new ImmutablePair<>(96, 16));
         }
     };
     private final Map<String, byte[]> fieldValues;
         }
     };
     private final Map<String, byte[]> fieldValues;
@@ -45,7 +45,7 @@ public class Ethernet extends Packet {
      */
     public Ethernet() {
         super();
      */
     public Ethernet() {
         super();
-        fieldValues = new HashMap<String, byte[]>();
+        fieldValues = new HashMap<>();
         hdrFieldCoordMap = fieldCoordinates;
         hdrFieldsMap = fieldValues;
     }
         hdrFieldCoordMap = fieldCoordinates;
         hdrFieldsMap = fieldValues;
     }
@@ -56,7 +56,7 @@ public class Ethernet extends Packet {
      */
     public Ethernet(boolean writeAccess) {
         super(writeAccess);
      */
     public Ethernet(boolean writeAccess) {
         super(writeAccess);
-        fieldValues = new HashMap<String, byte[]>();
+        fieldValues = new HashMap<>();
         hdrFieldCoordMap = fieldCoordinates;
         hdrFieldsMap = fieldValues;
     }
         hdrFieldCoordMap = fieldCoordinates;
         hdrFieldsMap = fieldValues;
     }
index 7b93d5f19cc3f9dcdbdb85454bb128b64b84a7c6..3c5623475e20cf21b5afaf1db7df609c4642df40 100644 (file)
@@ -57,7 +57,7 @@ public class LLDPTLV extends Packet {
 
         private byte value;
 
 
         private byte value;
 
-        private TLVType(byte value) {
+        TLVType(byte value) {
             this.value = value;
         }
 
             this.value = value;
         }
 
@@ -70,9 +70,9 @@ public class LLDPTLV extends Packet {
         private static final long serialVersionUID = 1L;
 
         {
         private static final long serialVersionUID = 1L;
 
         {
-            put(TYPE, new MutablePair<Integer, Integer>(0, 7));
-            put(LENGTH, new MutablePair<Integer, Integer>(7, 9));
-            put(VALUE, new MutablePair<Integer, Integer>(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;
      */
     public LLDPTLV() {
         payload = null;
-        fieldValues = new HashMap<String, byte[]>(LLDPTLVFields);
+        fieldValues = new HashMap<>(LLDPTLVFields);
         hdrFieldCoordMap = fieldCoordinates;
         hdrFieldsMap = fieldValues;
     }
         hdrFieldCoordMap = fieldCoordinates;
         hdrFieldsMap = fieldValues;
     }
index 0aae75deddb88938d70f53453e813dd2a1e68e54..334ccc2cc37555eef73488a013ae182e4b3d8b38 100644 (file)
@@ -103,7 +103,7 @@ public abstract class AbstractDispatcher<S extends ProtocolSession<?>, L extends
 
             @Override
             protected void initChannel(final CH ch) {
 
             @Override
             protected void initChannel(final CH ch) {
-                initializer.initializeChannel(ch, new DefaultPromise<S>(executor));
+                initializer.initializeChannel(ch, new DefaultPromise<>(executor));
             }
         });
 
             }
         });
 
index 6c4af0186f911a672902a2e7ad941d5791b95938..331e94949e2506a470ad31dae5de31cb12d256f3 100644 (file)
@@ -277,7 +277,7 @@ public class ServerTest {
                     }
                 };
             }
                     }
                 };
             }
-        }, new DefaultPromise<SimpleSession>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
+        }, new DefaultPromise<>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
 
         final ReconnectStrategyFactory reconnectStrategyFactory = mock(ReconnectStrategyFactory.class);
         final ReconnectStrategy reconnectStrategy = getMockedReconnectStrategy();
 
         final ReconnectStrategyFactory reconnectStrategyFactory = mock(ReconnectStrategyFactory.class);
         final ReconnectStrategy reconnectStrategy = getMockedReconnectStrategy();
@@ -303,7 +303,7 @@ public class ServerTest {
                                                                          final Channel channel, final Promise<SimpleSession> promise) {
                 return new SimpleSessionNegotiator(promise, channel);
             }
                                                                          final Channel channel, final Promise<SimpleSession> promise) {
                 return new SimpleSessionNegotiator(promise, channel);
             }
-        }, new DefaultPromise<SimpleSession>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
+        }, new DefaultPromise<>(GlobalEventExecutor.INSTANCE), eventLoopGroup);
     }
 
     private ReconnectStrategy getMockedReconnectStrategy() throws Exception {
     }
 
     private ReconnectStrategy getMockedReconnectStrategy() throws Exception {
index 7004ee61417d3af11f091e223419ba52a36ed89d..5d167566f2635fc8e839e4d5f633ecc05ed04704 100644 (file)
@@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
 public class SimpleSessionListener implements SessionListener<SimpleMessage, SimpleSession, TerminationReason> {
     private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
 
 public class SimpleSessionListener implements SessionListener<SimpleMessage, SimpleSession, TerminationReason> {
     private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
 
-    public List<SimpleMessage> messages = new ArrayList<SimpleMessage>();
+    public List<SimpleMessage> messages = new ArrayList<>();
 
     public boolean up = false;
 
 
     public boolean up = false;