diff options
Diffstat (limited to 'vpp-common/vpp-translate-utils')
-rw-r--r-- | vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/AddressTranslator.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/AddressTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/AddressTranslator.java index 170ff43e5..b602dc569 100644 --- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/AddressTranslator.java +++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/AddressTranslator.java @@ -18,6 +18,7 @@ package io.fd.hc2vpp.common.translate.util; import static com.google.common.base.Preconditions.checkNotNull; +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.Ipv4Address; @@ -68,4 +69,10 @@ public interface AddressTranslator extends Ipv4Translator, Ipv6Translator, MacTr return new IpAddress(arrayToIpv4AddressNoZone(ip)); } } + + // safest way to compare addresses - prevents returning false while using different types from hierarchy + // Ex. Key for MapResolver contains Ipv4Address as value but we translate addresses from binary data to Ipv4AddressNoZone + default boolean addressesEqual(final IpAddress left, final IpAddress right) { + return Arrays.equals(left.getValue(), right.getValue()); + } } |