2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120;
10 import java.util.regex.Pattern;
14 * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
15 * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
17 * The reason behind putting it under src/main/java is:
18 * 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
22 public final class RouteDistinguisherBuilder {
24 private static final Pattern RD_TWO_OCTET_AS =
26 + "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
27 + "[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|"
28 + "65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])"
30 + "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
31 + "[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|"
32 + "[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
33 + "[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
34 + "4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
35 + "429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|"
36 + "42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|"
37 + "42949672[0-8][0-9]|429496729[0-5])");
39 private static final Pattern RD_IPV4 =
40 Pattern.compile("((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
41 + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))"
43 + "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
44 + "[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|"
45 + "65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])");
47 private static final Pattern RD_AS =
48 Pattern.compile("([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
49 + "[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|"
50 + "[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
51 + "[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
52 + "4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|"
53 + "429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|"
54 + "42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|"
55 + "42949672[0-8][0-9]|429496729[0-5])"
57 + "([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|"
58 + "[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|"
59 + "65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])");
61 private RouteDistinguisherBuilder() {
65 public static RouteDistinguisher getDefaultInstance(final java.lang.String defaultValue) {
66 if (RD_TWO_OCTET_AS.matcher(defaultValue).matches()) {
67 return new RouteDistinguisher((new RdTwoOctetAs(defaultValue)));
68 } else if (RD_IPV4.matcher(defaultValue).matches()) {
69 return new RouteDistinguisher(new RdIpv4(defaultValue));
70 } else if (RD_AS.matcher(defaultValue).matches()) {
71 return new RouteDistinguisher(new RdAs(defaultValue));
73 throw new IllegalArgumentException("Cannot create Route Distinguisher from " + defaultValue);