Remove superfluous constants 00/86700/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 4 Jan 2020 15:15:26 +0000 (16:15 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 4 Jan 2020 15:47:27 +0000 (16:47 +0100)
java.lang.{Byte,Short,Integer,Long,Float} define a BYTES constant
since Java 8, use that instead of brewing our own.

Change-Id: If7a8e75c123fef7d79172f22dadb01012de4b1b5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 files changed:
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/PathIdUtil.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/message/StatisticsReportHandler.java
bmp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/TlvUtil.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPOverloadObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPProcTimeObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/AdminStatusObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/FlowSpecObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/InformationalFastRerouteObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/MetricObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/ProtectionCommonParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/SenderTspecObjectParser.java
util/src/main/java/org/opendaylight/protocol/util/ByteBufWriteUtil.java
util/src/test/java/org/opendaylight/protocol/util/ByteBufWriteUtilTest.java

index 081226d3fe5b82c9759904ffdeb3cb8990790709..950a8535a753ef2c3f47dc2fc85ce2c3571b3d47 100644 (file)
@@ -56,7 +56,7 @@ public final class PathIdUtil {
      * @return Decoded PathId.
      */
     public static PathId readPathId(final ByteBuf buffer) {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(ByteBufWriteUtil.INT_BYTES_LENGTH));
+        Preconditions.checkArgument(buffer != null && buffer.isReadable(Integer.BYTES));
         return new PathId(ByteBufUtils.readUint32(buffer));
     }
 
index fc5340de15b373fd6c68176b260b9ca709b3e63c..ba9282873e54571ad04aa6c4f420ec5dc1c1850c 100644 (file)
@@ -5,10 +5,8 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.bmp.parser.message;
 
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.INT_BYTES_LENGTH;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
 import com.google.common.base.Preconditions;
@@ -62,7 +60,7 @@ public class StatisticsReportHandler extends AbstractBmpPerPeerMessageParser<Tlv
         final StatsReportsMessageBuilder statReport = new StatsReportsMessageBuilder()
                 .setPeerHeader(parsePerPeerHeader(bytes));
         final TlvsBuilder tlvsBuilder = new TlvsBuilder();
-        bytes.skipBytes(INT_BYTES_LENGTH);
+        bytes.skipBytes(Integer.BYTES);
         parseTlvs(tlvsBuilder, bytes);
 
         return statReport.setTlvs(tlvsBuilder.build()).build();
index fa147583c24b0333320a40cdcd3b178152a56b12..5c5f5619137bbc13ca0ee5f8d30a45ca0194337c 100644 (file)
@@ -5,13 +5,8 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.bmp.spi.parser;
 
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.INT_BYTES_LENGTH;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.LONG_BYTES_LENGTH;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.SHORT_BYTES_LENGTH;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.nio.charset.StandardCharsets;
@@ -31,20 +26,20 @@ public final class TlvUtil {
     }
 
     public static void formatTlvShort16(final int type, final int value, final ByteBuf out) {
-        formatTlvHeader(type, SHORT_BYTES_LENGTH, out);
+        formatTlvHeader(type, Short.BYTES, out);
         ByteBufWriteUtil.writeUnsignedShort(value, out);
     }
 
     public static void formatTlvCounter32(final int type, final Counter32 value, final ByteBuf out) {
         if (value != null && value.getValue() != null) {
-            formatTlvHeader(type, INT_BYTES_LENGTH, out);
+            formatTlvHeader(type, Integer.BYTES, out);
             ByteBufWriteUtil.writeUnsignedInt(value.getValue(), out);
         }
     }
 
     public static void formatTlvGauge64(final int type, final Gauge64 value, final ByteBuf out) {
         if (value != null && value.getValue() != null) {
-            formatTlvHeader(type, LONG_BYTES_LENGTH, out);
+            formatTlvHeader(type, Long.BYTES, out);
             ByteBufWriteUtil.writeUnsignedLong(value.getValue(), out);
         }
     }
index 73389036849b9ae6de4acd048c00577186f6f691..e0961f94c0539c7e1655bf5e0d8a8641b7d65c10 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.pcep.parser.object;
 
 import com.google.common.base.Preconditions;
@@ -28,7 +27,7 @@ public class PCEPOverloadObjectParser extends CommonObjectParser implements Obje
     private static final int TYPE = 1;
     private static final int RESERVED = 1;
     private static final int FLAGS = RESERVED;
-    private static final int BODY_SIZE = RESERVED + FLAGS + ByteBufWriteUtil.SHORT_BYTES_LENGTH;
+    private static final int BODY_SIZE = RESERVED + FLAGS + Short.BYTES;
 
     public PCEPOverloadObjectParser() {
         super(CLASS, TYPE);
index 20c1b9341ef3d721d791370d779d85aca16706d9..091b87b2f4af76ef5def7c423ae4b6857a764730 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.protocol.pcep.parser.object;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.INT_BYTES_LENGTH;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -35,7 +34,7 @@ public class PCEPProcTimeObjectParser extends CommonObjectParser implements Obje
     private static final int RESERVED = 2;
     private static final int FLAGS = 16;
     private static final int COUNT_FIELDS = 5;
-    private static final int BODY_SIZE = RESERVED + FLAGS + COUNT_FIELDS * INT_BYTES_LENGTH;
+    private static final int BODY_SIZE = RESERVED + FLAGS + COUNT_FIELDS * Integer.BYTES;
     private static final int E_FLAG_POSITION = 15;
 
     public PCEPProcTimeObjectParser() {
index 686fdcfd4e988553d1e68d8026c4c4d50cc8553c..8dc45601beb143704c8508a977032483f31b643b 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.rsvp.parser.impl.te;
 
 import com.google.common.base.Preconditions;
@@ -13,7 +12,6 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.BitArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObjectBuilder;
@@ -32,7 +30,7 @@ public final class AdminStatusObjectParser extends AbstractRSVPObjectParser {
         final AdminStatusObjectBuilder adm = new AdminStatusObjectBuilder();
         final BitArray reflect = BitArray.valueOf(byteBuf, FLAGS_SIZE);
         adm.setReflect(reflect.get(REFLECT));
-        byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        byteBuf.skipBytes(Short.BYTES);
         final BitArray flags = BitArray.valueOf(byteBuf, FLAGS_SIZE);
         adm.setTesting(flags.get(TESTING));
         adm.setAdministrativelyDown(flags.get(DOWN));
index bfd47c47c431d6f1b4c62bddc54b00631ef6e74e..9ca3501e34f77679034796c0e0a04df786a79a6d 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.rsvp.parser.impl.te;
 
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
@@ -17,7 +16,6 @@ import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.protocol.util.ByteBufUtils;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ServiceNumber;
@@ -40,14 +38,14 @@ public final class FlowSpecObjectParser extends AbstractRSVPObjectParser {
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
         final FlowSpecObjectBuilder builder = new FlowSpecObjectBuilder();
         //skip version number, reserved, overall length
-        byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        byteBuf.skipBytes(Integer.BYTES);
         builder.setServiceHeader(ServiceNumber.forValue(byteBuf.readUnsignedByte()));
         //skip reserved
-        byteBuf.skipBytes(ByteBufWriteUtil.ONE_BYTE_LENGTH);
+        byteBuf.skipBytes(Byte.BYTES);
         //skip Length of controlled-load data
-        byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        byteBuf.skipBytes(Short.BYTES);
         //skip parameter ID 127 and 127 flags
-        byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        byteBuf.skipBytes(Integer.BYTES);
         final TspecObjectBuilder tBuilder = new TspecObjectBuilder()
                 .setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
                 .setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
@@ -57,7 +55,7 @@ public final class FlowSpecObjectParser extends AbstractRSVPObjectParser {
         builder.setTspecObject(tBuilder.build());
         if (builder.getServiceHeader().getIntValue() == 2) {
             //skip parameter ID 130, flags, lenght
-            byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
+            byteBuf.skipBytes(Integer.BYTES);
             builder.setRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
             builder.setSlackTerm(ByteBufUtils.readUint32(byteBuf));
         }
index ecc2761b8799da39643799eba543c18e615c7d44..b32be8e3dc5fd89927a964ac01fe64a7ff1fd87e 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.protocol.util.ByteBufUtils;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
@@ -36,7 +35,7 @@ public final class InformationalFastRerouteObjectParser extends AbstractRSVPObje
                 .setHopLimit(ByteBufUtils.readUint8(byteBuf));
 
         //skip reserved
-        byteBuf.skipBytes(ByteBufWriteUtil.ONE_BYTE_LENGTH);
+        byteBuf.skipBytes(Byte.BYTES);
         final ByteBuf v = byteBuf.readSlice(METRIC_VALUE_F_LENGTH);
         builder.setBandwidth(new Bandwidth(ByteArray.readAllBytes(v)));
         builder.setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
index 80c885d9d2cee2f47847c643156c6abd017702e9..1665cdfc8230ef5279422a987ad1e82a3ca7641d 100644 (file)
@@ -16,7 +16,6 @@ import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectPa
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.protocol.util.ByteBufUtils;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.metric.object.MetricObject;
@@ -31,7 +30,7 @@ public final class MetricObjectParser extends AbstractRSVPObjectParser {
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        byteBuf.skipBytes(Short.BYTES);
         final BitArray flags = BitArray.valueOf(byteBuf.readByte());
 
         return new MetricObjectBuilder()
index d73c50918ddea9c4c7e84abb4f7f3de5264779e1..738705bef6dda60b7683b6b95d449e4df1051e6a 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.protocol.rsvp.parser.impl.te;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.util.BitArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LinkFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspFlag;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject;
@@ -78,7 +77,7 @@ public class ProtectionCommonParser {
         final int lspFlags = byteBuf.readByte();
         sub.setLspFlag(LspFlag.forValue(lspFlags)).build();
         //Skip Reserved
-        byteBuf.skipBytes(ByteBufWriteUtil.ONE_BYTE_LENGTH);
+        byteBuf.skipBytes(Byte.BYTES);
         final int linkFlags = byteBuf.readByte();
         sub.setLinkFlags(LinkFlags.forValue(linkFlags));
 
@@ -88,7 +87,7 @@ public class ProtectionCommonParser {
 
         final int segFlags = byteBuf.readByte();
         sub.setSegFlag(LspFlag.forValue(segFlags));
-        byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        byteBuf.skipBytes(Short.BYTES);
         return sub.build();
     }
 
@@ -97,7 +96,7 @@ public class ProtectionCommonParser {
         final ProtectionSubobjectBuilder sub = new ProtectionSubobjectBuilder();
         sub.setSecondary(bitArray.get(SECONDARY));
         //Skip Reserved
-        byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        byteBuf.skipBytes(Short.BYTES);
         final int linkFlags = byteBuf.readByte();
         sub.setLinkFlags(LinkFlags.forValue(linkFlags));
         return sub.build();
index 2b47938921557dd38c0f7e5bf24b799ec94fc1e3..9979346f6a29ab0c34a57d9f6c364c58461a9c4d 100644 (file)
@@ -16,7 +16,6 @@ import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.protocol.util.ByteBufUtils;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject;
@@ -31,11 +30,11 @@ public class SenderTspecObjectParser extends AbstractRSVPObjectParser {
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
         //skip version number, reserved, Overall length
-        byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        byteBuf.skipBytes(Integer.BYTES);
         //skip Service header, reserved, Length of service
-        byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        byteBuf.skipBytes(Integer.BYTES);
         //skip Parameter ID, Parameter 127 flags, Parameter 127 length
-        byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        byteBuf.skipBytes(Integer.BYTES);
 
         return new TspecObjectBuilder()
                 .setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
@@ -54,7 +53,7 @@ public class SenderTspecObjectParser extends AbstractRSVPObjectParser {
         output.writeShort(0);
         output.writeShort(OVERALL_LENGTH);
         // FIXME: this is weird. Use explicit 1?
-        output.writeByte(ByteBufWriteUtil.ONE_BYTE_LENGTH);
+        output.writeByte(Byte.BYTES);
         output.writeByte(0);
         output.writeShort(SERVICE_LENGTH);
         output.writeByte(TOKEN_BUCKET_TSPEC);
index 991cca391ad094770e879dee9d84bae6e8071905..25e3c1d3670168e60891430ea336d44b6de950af 100644 (file)
@@ -27,19 +27,7 @@ import org.opendaylight.yangtools.yang.common.Uint8;
  * Utility class for ByteBuf's write methods.
  */
 public final class ByteBufWriteUtil {
-
-    public static final int SHORT_BYTES_LENGTH = Short.SIZE / Byte.SIZE;
-
-    public static final int INT_BYTES_LENGTH = Integer.SIZE / Byte.SIZE;
-
-    public static final int LONG_BYTES_LENGTH = Long.SIZE / Byte.SIZE;
-
-    public static final int FLOAT32_BYTES_LENGTH = INT_BYTES_LENGTH;
-
-    public static final int ONE_BYTE_LENGTH = 1;
-
     public static final int IPV4_PREFIX_BYTE_LENGTH = Ipv4Util.IP4_LENGTH + 1;
-
     public static final int IPV6_PREFIX_BYTE_LENGTH = Ipv6Util.IPV6_LENGTH + 1;
 
     private ByteBufWriteUtil() {
index 1a6db061dd005a08c85940d62008cdbc428b9d9d..6ca37cefa1d9d8b963177c0f810181b37647e70a 100644 (file)
@@ -50,7 +50,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteIntegerValue() {
         final byte[] result = { 0, 0, 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Integer.BYTES);
         writeInt(5, output);
         assertArrayEquals(result, output.array());
 
@@ -62,7 +62,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteShortValue() {
         final byte[] result = { 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Short.BYTES);
         writeShort((short) 5, output);
         assertArrayEquals(result, output.array());
 
@@ -87,7 +87,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteLongValue() {
         final byte[] result = { 0, 0, 0, 0, 0, 0, 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.LONG_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Long.BYTES);
         writeLong((long) 5, output);
         assertArrayEquals(result, output.array());
 
@@ -99,7 +99,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteBooleanValue() {
         final byte[] result = { 1 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.ONE_BYTE_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Byte.BYTES);
         writeBoolean(true, output);
         assertArrayEquals(result, output.array());
 
@@ -111,7 +111,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteUnsignedByteValue() {
         final byte[] result = { 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.ONE_BYTE_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Byte.BYTES);
         writeUnsignedByte(Uint8.valueOf(5), output);
         assertArrayEquals(result, output.array());
 
@@ -123,7 +123,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteUnsignedShortValue() {
         final byte[] result = { 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Short.BYTES);
         writeUnsignedShort(Uint16.valueOf(5), output);
         assertArrayEquals(result, output.array());
 
@@ -135,7 +135,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteUnsignedIntValue() {
         final byte[] result = { 0, 0, 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.INT_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Integer.BYTES);
         ByteBufWriteUtil.writeUnsignedInt(Uint32.valueOf(5), output);
         assertArrayEquals(result, output.array());
 
@@ -147,7 +147,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteUnsignedLongValue() {
         final byte[] result = { 0, 0, 0, 0, 0, 0, 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.LONG_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Long.BYTES);
         writeUnsignedLong(Uint64.valueOf(5), output);
         assertArrayEquals(result, output.array());
 
@@ -212,7 +212,7 @@ public class ByteBufWriteUtilTest {
     @Test
     public void testWriteFloat32() {
         final byte[] result = { 0, 0, 0, 5 };
-        final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.FLOAT32_BYTES_LENGTH);
+        final ByteBuf output = Unpooled.buffer(Float.BYTES);
         writeFloat32(new Float32(result), output);
         assertArrayEquals(result, output.array());