summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
index 7b4b2d01e..f902f8985 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
@@ -117,21 +117,30 @@ public final class InterfaceUtils {
return vppPhysAddrToYang(vppPhysAddress, 0);
}
- public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, int startIndex) {
+ public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, final int startIndex) {
Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes");
final int endIndex = startIndex + PHYSICAL_ADDRESS_LENGTH;
checkArgument(endIndex <= vppPhysAddress.length,
"Invalid physical address size (%s) for given startIndex (%s), expected >= %s", vppPhysAddress.length,
startIndex, endIndex);
- StringBuilder physAddr = new StringBuilder();
+ return printHexBinary(vppPhysAddress, startIndex, endIndex);
+ }
+
+ public static String printHexBinary(@Nonnull final byte[] bytes) {
+ Objects.requireNonNull(bytes, "bytes array should not be null");
+ return printHexBinary(bytes, 0, bytes.length);
+ }
+
+ private static String printHexBinary(@Nonnull final byte[] bytes, final int startIndex, final int endIndex) {
+ StringBuilder str = new StringBuilder();
- appendHexByte(physAddr, vppPhysAddress[startIndex]);
+ appendHexByte(str, bytes[startIndex]);
for (int i = startIndex + 1; i < endIndex; i++) {
- physAddr.append(":");
- appendHexByte(physAddr, vppPhysAddress[i]);
+ str.append(":");
+ appendHexByte(str, bytes[i]);
}
- return physAddr.toString();
+ return str.toString();
}
/**