Sonar minor issues fix 11/27911/6
authorIveta Halanova <ihalanov@cisco.com>
Tue, 6 Oct 2015 05:58:42 +0000 (07:58 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 8 Oct 2015 15:50:01 +0000 (15:50 +0000)
removed redundant final modifiers, magic numbers

Change-Id: Ied2cc7e567ab624cb6c0f0950442e6fb5b3fdf3d
Signed-off-by: Iveta Halanova <ihalanov@cisco.com>
12 files changed:
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/NumericOneByteOperandParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/NumericTwoByteOperandParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/Util.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKey128SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKey32SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKey128SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKey32SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKey128SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKey32SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/rro/RROPathKey128SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/rro/RROPathKey32SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/AttributesObjectParser.java

index a5d90d59859b616fef84a067b3a89fc38249c7c6..ea05e9902ccbf368d1707fc86be365ea71223a75 100644 (file)
@@ -33,7 +33,7 @@ public final class NumericOneByteOperandParser extends AbstractNumericOperandPar
      * @param nlriByteBuf where the operands will be serialized
      */
     @Override
-    public final <T extends NumericOneByteValue> void serialize(final List<T> list, final ByteBuf nlriByteBuf) {
+    public <T extends NumericOneByteValue> void serialize(final List<T> list, final ByteBuf nlriByteBuf) {
         for (final T operand : list) {
             super.serialize(operand.getOp(), 1, nlriByteBuf);
             Util.writeShortest(operand.getValue(), nlriByteBuf);
@@ -42,7 +42,7 @@ public final class NumericOneByteOperandParser extends AbstractNumericOperandPar
 
     // TODO: duplicate code with NumericTwoByteValue
     @Override
-    public final<T extends NumericOneByteValue> String toString(final List<T> list) {
+    public <T extends NumericOneByteValue> String toString(final List<T> list) {
         final StringBuilder buffer = new StringBuilder();
         boolean isFirst = true;
         for (final T item : list) {
index b334558b34a413656f3e3f5fe2a2a6423666cf01..50d88feb79b50326f0459e23eeeb7423b1ee368b 100644 (file)
@@ -34,7 +34,7 @@ public final class NumericTwoByteOperandParser extends AbstractNumericOperandPar
      * @param nlriByteBuf where the operands will be serialized
      */
     @Override
-    public final <T extends NumericTwoByteValue> void serialize(final List<T> list, final ByteBuf nlriByteBuf) {
+    public <T extends NumericTwoByteValue> void serialize(final List<T> list, final ByteBuf nlriByteBuf) {
         for (final T operand : list) {
             final ByteBuf protoBuf = Unpooled.buffer();
             Util.writeShortest(operand.getValue(), protoBuf);
@@ -45,7 +45,7 @@ public final class NumericTwoByteOperandParser extends AbstractNumericOperandPar
 
     // TODO: duplicate code with NumericOneByteValue
     @Override
-    public final<T extends NumericTwoByteValue> String toString(final List<T> list) {
+    public <T extends NumericTwoByteValue> String toString(final List<T> list) {
         final StringBuilder buffer = new StringBuilder();
         boolean isFirst = true;
         for (final T item : list) {
index 9ae134984f0d50a33efb6ed983031166aeb47c78..27169e2d5c099061ebf3b4d8186470b70a40b93a 100644 (file)
@@ -27,7 +27,7 @@ public final class Util {
      * @param value integer to be written
      * @param buffer ByteBuf where the value will be written
      */
-    protected static final void writeShortest(final int value, final ByteBuf buffer) {
+    protected static void writeShortest(final int value, final ByteBuf buffer) {
         if (value <= Values.UNSIGNED_BYTE_MAX_VALUE) {
             buffer.writeByte(UnsignedBytes.checkedCast(value));
         } else if (value <= Values.UNSIGNED_SHORT_MAX_VALUE) {
index 910e7e5a6eb434fafa12b9112a1b1c06bf2c96f7..ee0832f0d8f6b30f446093c0a81b9f7d3a0dc2a3 100644 (file)
@@ -31,7 +31,7 @@ public class EROPathKey128SubobjectParser implements EROSubobjectParser {
 
     public static final int TYPE = 65;
 
-    private static final int PCE128_ID_F_LENGTH = 16;
+    protected static final int PCE128_ID_F_LENGTH = 16;
 
     private static final int CONTENT128_LENGTH = 2 + PCE128_ID_F_LENGTH;
 
index 837bda93312829d607e80ec85d93d23573de0eb2..8b12a688cd69fb8d3949295898c26faaa886d9d2 100644 (file)
@@ -62,12 +62,12 @@ public class EROPathKey32SubobjectParser implements EROSubobjectParser, EROSubob
             .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
         final ByteBuf body = Unpooled.buffer();
         Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
-        if(pk.getPceId().getBinary().length == 16) {
+        if(pk.getPceId().getBinary().length == EROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             EROPathKey128SubobjectParser.serializeSubobject(subobject,buffer);
         }
         Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pk.getPceId().getBinary().length == 4, "PceId 32 Bit required.");
+        Preconditions.checkArgument(pk.getPceId().getBinary().length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
         body.writeBytes(pk.getPceId().getBinary());
         EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
     }
index 05987614f178bb7335255d7cd5626bf0ecc3255e..7e382ca5ef919e0df6233d398dd1198697a098b5 100644 (file)
@@ -30,7 +30,7 @@ public class RROPathKey128SubobjectParser implements RROSubobjectParser {
 
     private static final int PK_F_LENGTH = 2;
 
-    private static final int PCE128_ID_F_LENGTH = 16;
+    protected static final int PCE128_ID_F_LENGTH = 16;
 
     private static final int PK_F_OFFSET = 0;
     private static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
index 2ae9a2ba8dcd09c8815d22e009c4b7c2dbbb5bce..36ef6697cc732a68117952c4e206c96719a0b05e 100644 (file)
@@ -62,12 +62,12 @@ public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubob
             .subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
         final ByteBuf body = Unpooled.buffer();
         Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
-        if(pk.getPceId().getBinary().length == 16) {
+        if(pk.getPceId().getBinary().length == RROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             RROPathKey128SubobjectParser.serializeSubobject(subobject,buffer);
         }
         Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pk.getPceId().getBinary().length == 4, "PceId 32 Bit required.");
+        Preconditions.checkArgument(pk.getPceId().getBinary().length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
         body.writeBytes(pk.getPceId().getBinary());
         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
     }
index 02d4b464bb90c13f05154e42902ae4a3ecbe719b..296220f85720af60450ff1ceeb454707f60163ec 100644 (file)
@@ -31,7 +31,7 @@ public class XROPathKey128SubobjectParser implements XROSubobjectParser {
 
     public static final int TYPE = 65;
 
-    private static final int PCE128_ID_F_LENGTH = 16;
+    protected static final int PCE128_ID_F_LENGTH = 16;
 
     private static final int CONTENT128_LENGTH = 2 + PCE128_ID_F_LENGTH;
 
index 2f607f721b1a85aec60338a08b053c3e6a18a00f..29e417b898201e32ecac259c88745e6d52e2922c 100644 (file)
@@ -61,12 +61,12 @@ public class XROPathKey32SubobjectParser implements XROSubobjectParser, XROSubob
             .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
         final ByteBuf body = Unpooled.buffer();
         Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
-        if(pk.getPceId().getBinary().length == 16) {
+        if(pk.getPceId().getBinary().length == XROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             XROPathKey128SubobjectParser.serializeSubobject(subobject,buffer);
         }
         Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pk.getPceId().getBinary().length == 4, "PceId 32 Bit required.");
+        Preconditions.checkArgument(pk.getPceId().getBinary().length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
         body.writeBytes(pk.getPceId().getBinary());
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
     }
index 0b41191fd0e8ba94d55f08aa7ea0b5365071c70a..07d948ed37748b9997ca759bcedd3ff18d3a0b95 100644 (file)
@@ -29,7 +29,7 @@ public class RROPathKey128SubobjectParser implements RROSubobjectParser {
 
     private static final int PK_F_LENGTH = 2;
 
-    private static final int PCE128_ID_F_LENGTH = 16;
+    protected static final int PCE128_ID_F_LENGTH = 16;
 
     private static final int PK_F_OFFSET = 0;
     private static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
index 71f42183e4a5765df39c918ec4007f6a1a191650..5375cb9d4a6073197f98f6a22909170e2dccd598 100644 (file)
@@ -60,11 +60,11 @@ public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubob
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
         final ByteBuf body = Unpooled.buffer();
         Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
-        if (pk.getPceId().getBinary().length == 16) {
+        if (pk.getPceId().getBinary().length == RROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             RROPathKey128SubobjectParser.serializeSubobject(subobject, buffer);
         }
         Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
-        Preconditions.checkArgument(pk.getPceId().getBinary().length == 4, "PathKey 32Bit is mandatory.");
+        Preconditions.checkArgument(pk.getPceId().getBinary().length == PCE_ID_F_LENGTH, "PathKey 32Bit is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
         body.writeBytes(pk.getPceId().getBinary());
         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
index 6d8cc904695f1923ae8ebc5bebdd3d7fe3e95f4f..a1ce228608cd0aca9117920d557aea40d067d659 100644 (file)
@@ -37,7 +37,7 @@ public final class AttributesObjectParser extends AbstractRSVPObjectParser {
     protected static final int TLV_HEADER_SIZE = 4;
     private static final Logger LOG = LoggerFactory.getLogger(AttributesObjectParser.class);
 
-    protected static final List<FlagContainer> parseFlag(final ByteBuf byteBuf) {
+    protected static List<FlagContainer> parseFlag(final ByteBuf byteBuf) {
         final List<FlagContainer> flagList = new ArrayList<>();
         while (byteBuf.isReadable()) {
             final byte[] value = ByteArray.readBytes(byteBuf, FLAG_TLV_SIZE);
@@ -47,13 +47,13 @@ public final class AttributesObjectParser extends AbstractRSVPObjectParser {
         return flagList;
     }
 
-    protected static final void serializeFlag(final List<FlagContainer> flagList, final ByteBuf bufferAux) {
-        for (FlagContainer flagContainer : flagList) {
+    protected static void serializeFlag(final List<FlagContainer> flagList, final ByteBuf bufferAux) {
+        for (final FlagContainer flagContainer : flagList) {
             bufferAux.writeBytes(flagContainer.getFlags());
         }
     }
 
-    protected static final void serializeTLV(final int tlvType, final int lenght, final ByteBuf value, final ByteBuf auxBuffer) {
+    protected static void serializeTLV(final int tlvType, final int lenght, final ByteBuf value, final ByteBuf auxBuffer) {
         auxBuffer.writeShort(tlvType);
         auxBuffer.writeShort(lenght);
         auxBuffer.writeBytes(value);
@@ -63,7 +63,7 @@ public final class AttributesObjectParser extends AbstractRSVPObjectParser {
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
         final LspAttributesObjectBuilder builder = new LspAttributesObjectBuilder();
 
-        List<SubobjectContainer> subObjectList = new ArrayList<>();
+        final List<SubobjectContainer> subObjectList = new ArrayList<>();
         while (byteBuf.isReadable()) {
             final int type = byteBuf.readUnsignedShort();
             final int length = byteBuf.readUnsignedShort();
@@ -86,20 +86,20 @@ public final class AttributesObjectParser extends AbstractRSVPObjectParser {
         final LspAttributesObject lspAttributesObject = (LspAttributesObject) teLspObject;
 
         final ByteBuf bufferAux = Unpooled.buffer();
-        int lenght = 0;
-        for (SubobjectContainer subObject : lspAttributesObject.getSubobjectContainer()) {
+        int length = 0;
+        for (final SubobjectContainer subObject : lspAttributesObject.getSubobjectContainer()) {
             final LspSubobject lspSubonject = subObject.getLspSubobject();
             if (lspSubonject instanceof FlagsTlv) {
                 final ByteBuf flagTLVValue = Unpooled.buffer();
                 final List<FlagContainer> flagList = ((FlagsTlv) lspSubonject).getFlagContainer();
-                lenght = FLAG_TLV_SIZE * flagList.size();
+                length = FLAG_TLV_SIZE * flagList.size();
                 serializeFlag(flagList, flagTLVValue);
-                serializeTLV(FLAG_TLV_TYPE, lenght, flagTLVValue, bufferAux);
-                lenght += TLV_HEADER_SIZE;
+                serializeTLV(FLAG_TLV_TYPE, length, flagTLVValue, bufferAux);
+                length += TLV_HEADER_SIZE;
             }
         }
 
-        serializeAttributeHeader(lenght, CLASS_NUM, CTYPE, byteAggregator);
+        serializeAttributeHeader(length, CLASS_NUM, CTYPE, byteAggregator);
         byteAggregator.writeBytes(bufferAux);
     }
 }