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.IpAddressBuilder;
4 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder;
5 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
9 * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
10 * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
12 * The reason behind putting it under src/main/java is:
13 * 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
17 public class SimpleAddressBuilder {
19 public static SimpleAddress getDefaultInstance(String defaultValue) {
20 SimpleAddress address = tryIpAddress(defaultValue);
21 if (address != null) {
25 address = tryIpPrefix(defaultValue);
26 if (address != null) {
30 address = tryMacAddress(defaultValue);
31 if (address != null) {
35 // XXX need support for MAC addresses and AS numbers
36 address = new SimpleAddress(new DistinguishedNameType(defaultValue));
41 private static SimpleAddress tryIpAddress(String defaultValue) {
43 SimpleAddress address = new SimpleAddress(IpAddressBuilder.getDefaultInstance(defaultValue));
45 } catch (IllegalArgumentException e) {
50 private static SimpleAddress tryIpPrefix(String defaultValue) {
52 SimpleAddress address = new SimpleAddress(IpPrefixBuilder.getDefaultInstance(defaultValue));
54 } catch (IllegalArgumentException e) {
59 private static SimpleAddress tryMacAddress(String defaultValue) {
61 SimpleAddress address = new SimpleAddress(new MacAddress(defaultValue));
63 } catch (IllegalArgumentException e) {