summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src/main/java/io
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-02-07 13:50:59 +0100
committerJan Srnicek <jsrnicek@cisco.com>2017-02-08 08:29:29 +0000
commit3cecf2cd177bbcb87ad0d5eb19e8e0c80a016a5d (patch)
tree54c7c6df14bf0013a7a8ac7de259388b60a3a9f6 /vpp-common/vpp-translate-utils/src/main/java/io
parent1e562c89ed44a33ffafd310a9e58a45bad65339e (diff)
HC2VPP-11/HC2VPP-12 - refactored ipv4/6 logic/tests
- all dumping logic moved under common abstract classes - added tests Change-Id: Ifdee84795bd8cf6f0d29349dd2cfcf9b2bbec1c9 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/main/java/io')
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java22
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java16
2 files changed, 17 insertions, 21 deletions
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java
index c4a4ba38e..664bdc37d 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java
@@ -16,20 +16,15 @@
package io.fd.hc2vpp.common.translate.util;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
import com.google.common.net.InetAddresses;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.*;
+
+import javax.annotation.Nonnull;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+
+import static com.google.common.base.Preconditions.*;
/**
* Trait providing logic for translation of ipv6-related data
@@ -104,9 +99,7 @@ public interface Ipv6Translator extends ByteDataTranslator {
/**
* Detects whether {@code IpAddress} is ipv6
*/
- default boolean isIpv6(IpAddress address) {
- checkNotNull(address, "Address cannot be null");
-
+ default boolean isIpv6(@Nonnull final IpAddress address) {
checkState(!(address.getIpv4Address() == null && address.getIpv6Address() == null), "Invalid address");
return address.getIpv6Address() != null;
}
@@ -114,8 +107,7 @@ public interface Ipv6Translator extends ByteDataTranslator {
/**
* Detects whether {@code IpPrefix} is ipv6
*/
- default boolean isIpv6(IpPrefix address) {
- checkNotNull(address, "Address cannot be null");
+ default boolean isIpv6(@Nonnull final IpPrefix address) {
checkState(!(address.getIpv4Prefix() == null && address.getIpv6Prefix() == null), "Invalid address");
return address.getIpv6Prefix() != null;
}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java
index db656e721..d55446c82 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/JvppReplyConsumer.java
@@ -16,20 +16,21 @@
package io.fd.hc2vpp.common.translate.util;
-import static com.google.common.base.Preconditions.checkArgument;
-
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.dto.JVppReply;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import static com.google.common.base.Preconditions.checkArgument;
/**
* Trait providing logic for consuming reply's to jvpp api calls
@@ -38,6 +39,9 @@ public interface JvppReplyConsumer {
int DEFAULT_TIMEOUT_IN_SECONDS = 5;
+ JvppReplyConsumer INSTANCE = new JvppReplyConsumer() {
+ };
+
/**
* Consumes reply for jvpp call representing any write operation
* Should be used in case of calls where it's not clear which write crud operation respective