@Override protected String ipv6AddressString(final Ipv6Address addr) { return addr.getValue(); }
public static Ipv6Address getDefaultInstance(String defaultValue) { return new Ipv6Address(defaultValue); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4Address == null) ? 0 : _ipv4Address.hashCode()); result = prime * result + ((_ipv6Address == null) ? 0 : _ipv6Address.hashCode()); result = prime * result + ((_value == null) ? 0 : Arrays.hashCode(_value)); return result; }
return false; } else if(!_ipv6Address.equals(other._ipv6Address)) { return false;
@ConstructorProperties("value") public Ipv6Address(java.lang.String _value) { if (_value != null) { check_valueLength(_value); } Preconditions.checkNotNull(_value, "Supplied value may not be null"); for (Pattern p : patterns) { Preconditions.checkArgument(p.matcher(_value).matches(), "Supplied value \"%s\" does not match required pattern \"%s\"", _value, p); } this._value = _value; }
return false; } else if(!_ipv6Address.equals(other.getIpv6Address())) { return false;
public IpAddress(Ipv6Address _ipv6Address) { super(); this._ipv6Address = _ipv6Address; this._ipv4Address = null; this._value = _ipv6Address.getValue().toString().toCharArray(); }
public static Ipv6Address getDefaultInstance(String defaultValue) { return new Ipv6Address(defaultValue); }
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_afi == null) ? 0 : _afi.hashCode()); result = prime * result + ((_ipv6Address == null) ? 0 : _ipv6Address.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }
return false; } else if(!_ipv6Address.equals(other.getIpv6Address())) { return false;
public char[] getValue() { if (_value == null) { if (_ipv4Address != null) { _value = _ipv4Address.getValue().toString().toCharArray(); } else if (_ipv6Address != null) { _value = _ipv6Address.getValue().toString().toCharArray(); } } return _value == null ? null : _value.clone(); }
public static IpAddress getDefaultInstance(final String defaultValue) { final Matcher ipv4Matcher = IPV4_PATTERN.matcher(defaultValue); if (ipv4Matcher.matches()) { if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { throw new IllegalArgumentException( String.format("Cannot create IpAddress from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpAddress(new Ipv4Address(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpAddress(new Ipv6Address(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } }
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_afi == null) ? 0 : _afi.hashCode()); result = prime * result + ((_ipv6Address == null) ? 0 : _ipv6Address.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }
return false; } else if(!_teRouterIdIpv6.equals(other.getTeRouterIdIpv6())) { return false;
public static String getStringIpAddress(IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
public static IpAddress getDefaultInstance(final String defaultValue) { final Matcher ipv4Matcher = IPV4_PATTERN.matcher(defaultValue); if (ipv4Matcher.matches()) { if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { throw new IllegalArgumentException( String.format("Cannot create IpAddress from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpAddress(new Ipv4Address(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpAddress(new Ipv6Address(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } }
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_ipv4LocalAddress == null) ? 0 : _ipv4LocalAddress.hashCode()); result = prime * result + ((_ipv6LocalAddress == null) ? 0 : _ipv6LocalAddress.hashCode()); result = prime * result + ((_pccCapabilities == null) ? 0 : _pccCapabilities.hashCode()); result = prime * result + ((_teRouterIdIpv4 == null) ? 0 : _teRouterIdIpv4.hashCode()); result = prime * result + ((_teRouterIdIpv6 == null) ? 0 : _teRouterIdIpv6.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }
return false; } else if(!_teRouterIdIpv6.equals(other.getTeRouterIdIpv6())) { return false;
private InetSocketAddress getInetAddress() { try { final InetAddress inetAd = InetAddress.getByName(getBindingAddress().getIpv4Address() == null ? getBindingAddress().getIpv6Address().getValue() : getBindingAddress().getIpv4Address().getValue()); return new InetSocketAddress(inetAd, getPort().getValue()); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Unable to bind netconf endpoint to address " + getBindingAddress(), e); } }
/** * This implementation does not use nameservice lookups (e.g. no DNS). * * @param ipAddress - format must be valid for regex in {@link Ipv4Address} or * {@link Ipv6Address} * @return the {@link IpAddress} having the given ipAddress string representation * @throws IllegalArgumentException - if the argument is not a valid IP address string */ public static IpAddress createIpAddress(String ipAddress) { checkArgument(!Strings.isNullOrEmpty(ipAddress), "Cannot be null or empty."); InetAddress ip = InetAddresses.forString(ipAddress); if (ip instanceof Inet4Address) { return new IpAddress(new Ipv4Address(ipAddress)); } return new IpAddress(new Ipv6Address(ipAddress)); }