use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily in project lispflowmapping by opendaylight.
the class LispAddressUtil method convertFromBinary.
private static Pair<Class<? extends LispAddressFamily>, Address> convertFromBinary(Address addr) {
Address convAddr = null;
Class<? extends LispAddressFamily> convType = null;
if (addr instanceof Ipv4PrefixBinary) {
convAddr = convertFromBinary((Ipv4PrefixBinary) addr);
convType = Ipv4PrefixAfi.class;
} else if (addr instanceof Ipv6PrefixBinary) {
convAddr = convertFromBinary((Ipv6PrefixBinary) addr);
convType = Ipv6PrefixAfi.class;
} else if (addr instanceof Ipv4Binary) {
convAddr = convertFromBinary((Ipv4Binary) addr);
convType = Ipv4Afi.class;
} else if (addr instanceof Ipv6Binary) {
convAddr = convertFromBinary((Ipv6Binary) addr);
convType = Ipv6Afi.class;
}
return new ImmutablePair<Class<? extends LispAddressFamily>, Address>(convType, convAddr);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromSimpleAddressTest_asMacAddress.
/**
* Tests {@link LispAddressUtil#addressTypeFromSimpleAddress} and {@link
* LispAddressUtil#addressFromSimpleAddress} methods
* with mac address.
*/
@Test
public void addressFromSimpleAddressTest_asMacAddress() {
final SimpleAddress simpleAddress = new SimpleAddress(new MacAddress(MAC_ADDRESS_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromSimpleAddress(simpleAddress);
assertEquals(MacAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromSimpleAddress(simpleAddress);
assertTrue(address instanceof Mac);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromSimpleAddressTest_asNumber.
/**
* Tests {@link LispAddressUtil#addressTypeFromSimpleAddress} and {@link
* LispAddressUtil#addressFromSimpleAddress} methods
* with address as number.
*/
@Test
public void addressFromSimpleAddressTest_asNumber() {
final SimpleAddress simpleAddress = new SimpleAddress(new AsNumber(NUMBER_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromSimpleAddress(simpleAddress);
assertEquals(AsNumberAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromSimpleAddress(simpleAddress);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AsNumber);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpPrefix_null.
/**
* Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link LispAddressUtil#addressTypeFromIpPrefix
* (IpPrefix)}
* methods with null value instead off address.
*/
@Test
public void addressFromIpPrefix_null() {
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(null);
assertNull(addressClass);
final Address address = LispAddressUtil.addressFromIpPrefix(null);
assertNull(address);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpPrefix_ipv6.
/**
* Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link
* LispAddressUtil#addressTypeFromIpPrefix(IpPrefix)}
* methods with ipv6 address.
*/
@Test
public void addressFromIpPrefix_ipv6() {
IpPrefix ipv6Address = new IpPrefix(new Ipv6Prefix(IPV6_ADDRESS_PREFIX_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(ipv6Address);
assertEquals(Ipv6PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromIpPrefix(ipv6Address);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix);
assertEquals(IPV6_ADDRESS_PREFIX_VALUE_TEST, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) address).getIpv6Prefix().getValue());
}
Aggregations