summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-11-27 07:50:49 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-11-27 08:05:50 +0100
commit826e9fd8de53fdf7bfe3a408d6ecba02e4359c7e (patch)
treeb426cf15450e109a97793e7d096216dafe644074
parentfc838c481e6f588906f6282ee1891b4b98ab1779 (diff)
Remove unnecessary boxing and unboxing
Change-Id: I9f7cf7d7ecb97d7da449dac679f2d15438ac4970 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java4
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java2
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java2
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java16
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java22
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java14
6 files changed, 23 insertions, 37 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java
index 42c41ed93..bb960fe92 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java
@@ -116,8 +116,8 @@ public class InterfaceCustomizer
final String interfaceRef = interfaceContext.getName(details.swIfIndex, ctx.getMappingContext());
- builder.setPriority(Byte.valueOf(details.priority).shortValue());
- builder.setWeight(Byte.valueOf(details.weight).shortValue());
+ builder.setPriority((short) Byte.toUnsignedInt(details.priority));
+ builder.setWeight((short) Byte.toUnsignedInt(details.weight));
builder.setInterfaceRef(interfaceRef);
builder.setKey(new InterfaceKey(interfaceRef));
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java
index 2190ddf6b..7d49a8d30 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java
@@ -110,7 +110,7 @@ public class LocalMappingCustomizer
//Requesting for specific mapping dump,only from local mappings with specified eid/vni/eid type
final MappingsDumpParams dumpParams = new MappingsDumpParams.MappingsDumpParamsBuilder()
.setEidSet(QuantityType.SPECIFIC)
- .setVni(Long.valueOf(vni).intValue())
+ .setVni((int) vni)
.setEid(getEidAsByteArray(eid))
.setEidType(getEidType(eid))
.setPrefixLength(getPrefixLength(eid))
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java
index 0d9aec5fb..4f497c350 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java
@@ -71,7 +71,7 @@ public class VniTableCustomizer extends CheckedLispCustomizer
}
private static VniTableKey detailsToKey(final OneEidTableVniDetails lispEidTableMapDetails) {
- return new VniTableKey(Integer.valueOf(lispEidTableMapDetails.vni).longValue());
+ return new VniTableKey(Integer.toUnsignedLong(lispEidTableMapDetails.vni));
}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java
index 599d450d2..bad51478d 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactory.java
@@ -67,7 +67,7 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement
route.getDestinationPrefix(),
nextHopInterfaceIndex,
hop.getAddress(),
- toByte(hop.getWeight()),
+ hop.getWeight().byteValue(),
getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext),
DEFAULT_VNI,
classifyTableIndex(routingAttributes.getClassifyTable(), getVppClassifierContextManager(),
@@ -78,7 +78,7 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement
route.getDestinationPrefix(),
nextHopInterfaceIndex,
hop.getAddress(),
- toByte(hop.getWeight()),
+ hop.getWeight().byteValue(),
getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext),
DEFAULT_VNI,
0,
@@ -102,7 +102,7 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement
route.getDestinationPrefix(),
nextHopInterfaceIndex,
hop.getAddress(),
- toByte(hop.getWeight()),
+ hop.getWeight().byteValue(),
getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext),
DEFAULT_VNI,
classifyTableIndex(routingAttributes.getClassifyTable(), getVppClassifierContextManager(),
@@ -113,7 +113,7 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement
route.getDestinationPrefix(),
nextHopInterfaceIndex,
hop.getAddress(),
- toByte(hop.getWeight()),
+ hop.getWeight().byteValue(),
getRoutingProtocolContext().getIndex(parentProtocolName, mappingContext),
DEFAULT_VNI,
0,
@@ -129,8 +129,8 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement
final int primaryVrf, final int secondaryVrf,
final int classifyTableIndex, final boolean classifyIndexSet) {
return flaglessAddDelRouteRequest(booleanToByte(isAdd), nextHopInterfaceIndex,
- ipv6AddressNoZoneToArray(nextHopAddress), nextHopWeight, toByte(1),
- ipv6AddressPrefixToArray(destinationAddress), extractPrefix(destinationAddress.getValue()), toByte(1),
+ ipv6AddressNoZoneToArray(nextHopAddress), nextHopWeight, (byte)1,
+ ipv6AddressPrefixToArray(destinationAddress), extractPrefix(destinationAddress.getValue()), (byte)1,
primaryVrf, secondaryVrf, classifyTableIndex,
booleanToByte(classifyIndexSet));
}
@@ -142,8 +142,8 @@ public class MultipathHopRequestFactory extends BasicHopRequestFactory implement
final int primaryVrf, final int secondaryVrf,
final int classifyTableIndex, final boolean classifyIndexSet) {
return flaglessAddDelRouteRequest(booleanToByte(isAdd), nextHopInterfaceIndex,
- ipv4AddressNoZoneToArray(nextHopAddress.getValue()), nextHopWeight, toByte(0),
- ipv4AddressPrefixToArray(destinationAddress), extractPrefix(destinationAddress.getValue()), toByte(1),
+ ipv4AddressNoZoneToArray(nextHopAddress.getValue()), nextHopWeight, (byte)0,
+ ipv4AddressPrefixToArray(destinationAddress), extractPrefix(destinationAddress.getValue()), (byte)1,
primaryVrf, secondaryVrf, classifyTableIndex,
booleanToByte(classifyIndexSet));
}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java
index b1703be26..dd6ba37d2 100644
--- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java
@@ -97,25 +97,25 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd
final int isProhibit) {
final IpAddDelRoute request = new IpAddDelRoute();
- request.isAdd = toByte(add);
- request.isIpv6 = toByte(ipv6);
- request.isMultipath = toByte(isMultipath);
+ request.isAdd = (byte)add;
+ request.isIpv6 = (byte)ipv6;
+ request.isMultipath = (byte)isMultipath;
request.dstAddress = destinationAddress;
- request.dstAddressLength = toByte(destinationPrefixLength);
+ request.dstAddressLength = (byte)destinationPrefixLength;
request.nextHopAddress = nextHopAddr;
request.nextHopSwIfIndex = nextHopIndex;
- request.nextHopWeight = toByte(nextHopWeight);
+ request.nextHopWeight = (byte)nextHopWeight;
request.classifyTableIndex = classifyTableIndexSet;
request.tableId = vrfId;
request.nextHopTableId = secondaryVrfId;
- request.createVrfIfNeeded = toByte(createVrfIfNeeded);
+ request.createVrfIfNeeded = (byte)createVrfIfNeeded;
request.classifyTableIndex = classifyTableIndex;
- request.isClassify = toByte(classifyTableIndexSet);
+ request.isClassify = (byte)classifyTableIndexSet;
// special hop flags
- request.isDrop = toByte(isDrop);
- request.isLocal = toByte(isLocal);
- request.isUnreach = toByte(isUnreach);
- request.isProhibit = toByte(isProhibit);
+ request.isDrop = (byte)isDrop;
+ request.isLocal = (byte)isLocal;
+ request.isUnreach = (byte)isUnreach;
+ request.isProhibit = (byte)isProhibit;
request.nextHopViaLabel = RouteRequestProducer.MPLS_LABEL_INVALID;
return request;
}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java
index c7583fb52..fc511d714 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java
@@ -45,20 +45,6 @@ public interface ByteDataTranslator {
}
/**
- * Converts int to byte.
- */
- default byte toByte(final int value) {
- return Integer.valueOf(value).byteValue();
- }
-
- /**
- * Converts short to byte.
- */
- default byte toByte(final short value) {
- return Short.valueOf(value).byteValue();
- }
-
- /**
* Checks if provided array contains only zeros
*/
default boolean isArrayZeroed(final byte[] arr) {