summaryrefslogtreecommitdiffstats
path: root/v3po/vpp-translate-utils
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-06-13 14:58:50 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-06-15 10:32:09 +0000
commitcc306a6e41824f2de2fe9f3cd2f788c7e5c41cd5 (patch)
tree537b1ae2d6b17f003e2fec0dfddd9cbaf17ab4fa /v3po/vpp-translate-utils
parentcb00de1bc91091060dfb688876b45b7dc740318e (diff)
HONEYCOMB-91: initializer for L2 FIB tables
Change-Id: I7f133ea56fc3bb11e0f4b584839dabc0754a8d50 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/vpp-translate-utils')
-rw-r--r--v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
index 9aed188d5..77e60877f 100644
--- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
+++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
@@ -40,7 +40,8 @@ public final class TranslateUtils {
public static final Splitter COLON_SPLITTER = Splitter.on(':');
- private TranslateUtils() {}
+ private TranslateUtils() {
+ }
public static <REP extends JVppReply<?>> REP getReply(Future<REP> future) throws VppBaseCallException {
try {
@@ -51,7 +52,7 @@ public final class TranslateUtils {
} catch (ExecutionException e) {
// Execution exception could generally contains any exception
// when using exceptions instead of return codes just rethrow it for processing on corresponding place
- if (e instanceof ExecutionException && ( e.getCause() instanceof VppBaseCallException)) {
+ if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
throw (VppBaseCallException) (e.getCause());
}
throw new IllegalStateException(e);
@@ -71,8 +72,9 @@ public final class TranslateUtils {
} catch (ExecutionException e) {
// Execution exception could generally contains any exception
// when using exceptions instead of return codes just rethrow it for processing on corresponding place
- if ( e.getCause() instanceof VppBaseCallException)
- throw (VppBaseCallException)(e.getCause());
+ if (e.getCause() instanceof VppBaseCallException) {
+ throw (VppBaseCallException) (e.getCause());
+ }
throw new IllegalStateException(e);
} catch (TimeoutException e) {
throw new ReadTimeoutException(replyType, e);
@@ -80,8 +82,8 @@ public final class TranslateUtils {
}
/**
- * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be
- * in the same order as the address.
+ * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
+ * as the address.
*
* @return byte array with address bytes
*/
@@ -104,7 +106,7 @@ public final class TranslateUtils {
@Nonnull
public static Ipv4AddressNoZone arrayToIpv4AddressNoZone(@Nonnull byte[] ip) {
// VPP sends ipv4 in a 16 byte array
- if(ip.length == 16) {
+ if (ip.length == 16) {
ip = Arrays.copyOfRange(ip, 0, 4);
}
try {
@@ -117,8 +119,8 @@ public final class TranslateUtils {
}
/**
- * Return (interned) string from byte array while removing \u0000.
- * Strings represented as fixed length byte[] from vpp contain \u0000.
+ * Return (interned) string from byte array while removing \u0000. Strings represented as fixed length byte[] from
+ * vpp contain \u0000.
*/
public static String toString(final byte[] cString) {
return new String(cString).replaceAll("\\u0000", "").intern();
@@ -152,20 +154,24 @@ public final class TranslateUtils {
}
public static byte parseHexByte(final String aByte) {
- return (byte)Integer.parseInt(aByte, 16);
+ return (byte) Integer.parseInt(aByte, 16);
}
- /**
+ /**
* Returns 0 if argument is null or false, 1 otherwise.
+ *
* @param value Boolean value to be converted
* @return byte value equal to 0 or 1
*/
public static byte booleanToByte(@Nullable final Boolean value) {
- return value != null && value ? (byte) 1 : (byte) 0;
+ return value != null && value
+ ? (byte) 1
+ : (byte) 0;
}
/**
* Returns Boolean.TRUE if argument is 0, Boolean.FALSE otherwise.
+ *
* @param value byte value to be converted
* @return Boolean value
* @throws IllegalArgumentException if argument is neither 0 nor 1