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.http.openconfig.net.yang.network.instance.types.rev151018;
10 import java.util.regex.Pattern;
11 import org.opendaylight.yangtools.yang.binding.CodeHelpers;
14 * Helper builder utility for {@code RouteDistinguisher} union type.
16 public final class RouteDistinguisherBuilder {
17 private static final Pattern[] PATTERNS = CodeHelpers.compilePatterns(RouteDistinguisher.PATTERN_CONSTANTS);
19 private RouteDistinguisherBuilder() {
23 public static RouteDistinguisher getDefaultInstance(final String defaultValue) {
24 if (anyMatch(defaultValue)) {
25 return new RouteDistinguisher(defaultValue);
27 throw new IllegalArgumentException("Cannot create RouteDistinguisher from " + defaultValue);
30 private static boolean anyMatch(final String defaultValue) {
31 for (final Pattern pattern : PATTERNS) {
32 if (pattern.matcher(defaultValue).matches()) {