1 package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105;
3 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
4 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
8 * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
9 * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
11 * The reason behind putting it under src/main/java is:
12 * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
16 public class SimpleAddressBuilder {
18 public static SimpleAddress getDefaultInstance(String defaultValue) {
19 SimpleAddress address = tryIpAddress(defaultValue);
20 if (address != null) {
24 address = tryIpPrefix(defaultValue);
25 if (address != null) {
29 address = tryMacAddress(defaultValue);
30 if (address != null) {
34 // XXX need support for MAC addresses and AS numbers
35 address = new SimpleAddress(new DistinguishedNameType(defaultValue));
40 private static SimpleAddress tryIpAddress(String defaultValue) {
42 SimpleAddress address = new SimpleAddress(IetfInetUtil.ipAddressFor(defaultValue));
44 } catch (IllegalArgumentException e) {
49 private static SimpleAddress tryIpPrefix(String defaultValue) {
51 SimpleAddress address = new SimpleAddress(IetfInetUtil.ipPrefixFor(defaultValue));
53 } catch (IllegalArgumentException e) {
58 private static SimpleAddress tryMacAddress(String defaultValue) {
60 SimpleAddress address = new SimpleAddress(new MacAddress(defaultValue));
62 } catch (IllegalArgumentException e) {