@Override protected String ipv4PrefixString(final Ipv4Prefix prefix) { return prefix.getValue(); }
/** * Create ipv4 prefix from ipv4 address, by appending /32 mask * * @param ipv4AddressString the ip address, in string format * @return Ipv4Prefix with ipv4Address and /32 mask */ public static Ipv4Prefix iPv4PrefixFromIPv4Address(String ipv4AddressString) { return new Ipv4Prefix(ipv4AddressString + "/32"); }
@Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Ipv4LocalAddressKey other = (Ipv4LocalAddressKey) obj; if (_ipv4Prefix == null) { if (other._ipv4Prefix != null) { return false; } } else if(!_ipv4Prefix.equals(other._ipv4Prefix)) { return false; } return true; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4Prefix == null) ? 0 : _ipv4Prefix.hashCode()); return result; }
@ConstructorProperties("value") public Ipv4Prefix(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; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4Prefix == null) ? 0 : _ipv4Prefix.hashCode()); return result; }
public IpPrefix(Ipv4Prefix _ipv4Prefix) { super(); this._ipv4Prefix = _ipv4Prefix; this._ipv6Prefix = null; this._value = _ipv4Prefix.getValue().toString().toCharArray(); }
public static Ipv4Prefix getDefaultInstance(String defaultValue) { return new Ipv4Prefix(defaultValue); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4Destination == null) ? 0 : _ipv4Destination.hashCode()); result = prime * result + ((_ipv4Source == null) ? 0 : _ipv4Source.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); return result; }
@Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Ipv4LocalAddressKey other = (Ipv4LocalAddressKey) obj; if (_ipv4Prefix == null) { if (other._ipv4Prefix != null) { return false; } } else if(!_ipv4Prefix.equals(other._ipv4Prefix)) { return false; } return true; }
private static InetAddress inetAddressFrom(Ipv4Prefix source) { if (source != null) { String[] parts = source.getValue().split("/"); return InetAddresses.forString(parts[0]); } return null; }
public static Ipv4Prefix getDefaultInstance(String defaultValue) { return new Ipv4Prefix(defaultValue); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_tunnelIpv4Destination == null) ? 0 : _tunnelIpv4Destination.hashCode()); result = prime * result + ((_tunnelIpv4Source == null) ? 0 : _tunnelIpv4Source.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); return result; }
return false; } else if(!_ipv4Prefix.equals(other._ipv4Prefix)) { return false;
public char[] getValue() { if (_value == null) { if (_ipv4Prefix != null) { _value = _ipv4Prefix.getValue().toString().toCharArray(); } else if (_ipv6Prefix != null) { _value = _ipv6Prefix.getValue().toString().toCharArray(); } } return _value == null ? null : _value.clone(); }
public static IpPrefix 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 IpPrefix from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpPrefix(new Ipv4Prefix(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpPrefix(new Ipv6Prefix(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpPrefix from " + defaultValue); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4Address == null) ? 0 : _ipv4Address.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); return result; }
return false; } else if(!_ipv4Address.equals(other.getIpv4Address())) { return false;
/** * TODO: why don't we use the default Ipv4Prefix.equals()? * * @param statsIpAddress * @param storedIpAddress * @return true if IPv4prefixes equals */ private static boolean IpAddressEquals(final Ipv4Prefix statsIpAddress, final Ipv4Prefix storedIpAddress) { final IntegerIpAddress statsIpAddressInt = StrIpToIntIp(statsIpAddress.getValue()); final IntegerIpAddress storedIpAddressInt = StrIpToIntIp(storedIpAddress.getValue()); if(IpAndMaskBasedMatch(statsIpAddressInt,storedIpAddressInt)){ return true; } if(IpBasedMatch(statsIpAddressInt,storedIpAddressInt)){ return true; } return false; }
public static IpPrefix 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 IpPrefix from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpPrefix(new Ipv4Prefix(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpPrefix(new Ipv6Prefix(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpPrefix from " + defaultValue); } }