2 * Copyright (c) 2015 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.ietf.params.xml.ns.yang.ietf.inet.types.rev130715;
10 import static com.google.common.base.Verify.verify;
12 import java.util.regex.Pattern;
15 * Builder for {@link IpAddress} instances.
17 public class IpAddressBuilder {
18 private static final Pattern IPV4_PATTERN;
21 verify(Ipv4Address.PATTERN_CONSTANTS.size() == 1);
22 IPV4_PATTERN = Pattern.compile(Ipv4Address.PATTERN_CONSTANTS.get(0));
25 private IpAddressBuilder() {
29 public static IpAddress getDefaultInstance(final String defaultValue) {
30 return IPV4_PATTERN.matcher(defaultValue).matches() ? new IpAddress(new Ipv4Address(defaultValue))
31 : new IpAddress(new Ipv6Address(defaultValue));