public static Ipv4AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv4AddressNoZone(defaultValue); }
public IpAddressNoZone(Ipv4AddressNoZone _ipv4AddressNoZone) { super(); this._ipv4AddressNoZone = _ipv4AddressNoZone; this._ipv6AddressNoZone = null; this._value = _ipv4AddressNoZone.getValue().toString().toCharArray(); }
static Optional<IpAddressDetails> findIpAddressDetailsByIp( final Optional<IpAddressDetailsReplyDump> dump, @Nonnull final Ipv4AddressNoZone ip) { checkNotNull(ip, "ip address should not be null"); if (dump.isPresent() && dump.get().ipAddressDetails != null) { final List<IpAddressDetails> details = dump.get().ipAddressDetails; return Optional.of(details.stream() .filter(singleDetail -> ip.equals(TranslateUtils.arrayToIpv4AddressNoZone(singleDetail.ip))) .collect(RWUtils.singleItemCollector())); } return Optional.absent(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4AddressNoZone == null) ? 0 : _ipv4AddressNoZone.hashCode()); result = prime * result + ((_ipv6AddressNoZone == null) ? 0 : _ipv6AddressNoZone.hashCode()); result = prime * result + ((_value == null) ? 0 : Arrays.hashCode(_value)); return result; }
public static Ipv4AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv4AddressNoZone(defaultValue); }
/** * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order * as the address. * * @return byte array with address bytes */ public static byte[] ipv4AddressNoZoneToArray(final Ipv4AddressNoZone ipv4Addr) { return ipv4AddressNoZoneToArray(ipv4Addr.getValue()); }
@Nonnull protected Optional<IpAddressDetails> findIpv4AddressDetailsByIp( final Optional<IpAddressDetailsReplyDump> dump, @Nonnull final Ipv4AddressNoZone ip) { checkNotNull(ip, "ip address should not be null"); if (dump.isPresent() && dump.get().ipAddressDetails != null) { final List<IpAddressDetails> details = dump.get().ipAddressDetails; return Optional.of(details.stream() .filter(singleDetail -> ip.equals(arrayToIpv4AddressNoZone(singleDetail.ip))) .collect(RWUtils.singleItemCollector())); } return Optional.absent(); }
public static Ipv4AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv4AddressNoZone(defaultValue); }
/** * Creates a new instance from Ipv4Address * * @param source Source object */ public Ipv4AddressNoZone(Ipv4Address source) { super(source); CodeHelpers.checkPattern(getValue(), patterns, regexes); }
return false; } else if(!_ipv4AddressNoZone.equals(other._ipv4AddressNoZone)) { return false;
public static IpAddressNoZone getDefaultInstance(final String defaultValue) { if (IPV4_NO_ZONE_PATTERN.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv4AddressNoZone(defaultValue))); } else if (IPV6_NO_ZONE_PATTERN1.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv6AddressNoZone(defaultValue))); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
/** * Return a String representing the value of this union. * * @return String representation of this union's value. */ public String stringValue() { if (_ipv4AddressNoZone != null) { return _ipv4AddressNoZone.getValue().toString(); } if (_ipv6AddressNoZone != null) { return _ipv6AddressNoZone.getValue().toString(); } throw new IllegalStateException("No value assinged"); }
public static IpAddressNoZone getDefaultInstance(final String defaultValue) { if (IPV4_NO_ZONE_PATTERN.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv4AddressNoZone(defaultValue))); } else if (IPV6_NO_ZONE_PATTERN1.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv6AddressNoZone(defaultValue))); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
/** * Converts byte array to {@link Ipv4Prefix} with specified prefixLength */ public static Ipv4Prefix arrayToIpv4Prefix(final byte[] address, byte prefixLength) { Ipv4AddressNoZone addressPart = arrayToIpv4AddressNoZone(address); return new Ipv4Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength))); }
public static Ipv4AddressNoZone getIpv4Address(FcPort port) { String hostname = port.getNode().getValue(); String loopback = loopbackMap.get(hostname); if (loopback == null) { LOG.warn("No loopback address found for {}", hostname); loopback = DEFAULT_LOOPBACK; } return new Ipv4AddressNoZone(loopback); } }
public char[] getValue() { if (_value == null) { if (_ipv4AddressNoZone != null) { _value = _ipv4AddressNoZone.getValue().toString().toCharArray(); } else if (_ipv6AddressNoZone != null) { _value = _ipv6AddressNoZone.getValue().toString().toCharArray(); } } return _value == null ? null : _value.clone(); }
/** * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order. * * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No * change in order. */ @Nonnull public static Ipv4AddressNoZone arrayToIpv4AddressNoZone(@Nonnull byte[] ip) { // VPP sends ipv4 in a 16 byte array if (ip.length == 16) { ip = Arrays.copyOfRange(ip, 0, 4); } try { // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order // compared to byte order it was submitted return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip))); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unable to parse ipv4", e); } }
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix v4Prefix( final byte[] address, final byte prefix) { return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( prefixValue(INSTANCE.arrayToIpv4AddressNoZone(address).getValue(), String.valueOf(prefix))); }
/** * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order. * * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No * change in order. */ @Nonnull public static Ipv4AddressNoZone arrayToIpv4AddressNoZoneReversed(@Nonnull byte[] ip) { // VPP sends ipv4 in a 16 byte array if (ip.length == 16) { ip = Arrays.copyOfRange(ip, 0, 4); } ip = reverseBytes(ip); try { // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order // compared to byte order it was submitted return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip))); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unable to parse ipv4", e); } }
default String getArrayAsEidString(final EidType type, final byte[] address, final byte prefix) { switch (type) { case IPV4: { return prefix != DEFAULT_V4_PREFIX ? v4Prefix(address, prefix).getValue() : arrayToIpv4AddressNoZone(address).getValue(); } case IPV6: { return prefix != DEFAULT_V6_PREFIX ? v6Prefix(address, prefix).getValue() : arrayToIpv6AddressNoZone(address).getValue(); } case MAC: { //as wrong as it looks ,its right(second param is not end index,but count) return byteArrayToMacSeparated(Arrays.copyOfRange(address, 0, 6)); } case IPV4_PREFIX: { return v4Prefix(address, prefix).getValue(); } case IPV6_PREFIX: { return v6Prefix(address, prefix).getValue(); } default: { throw new IllegalStateException("Unknown type detected"); } } }