blob: fc4fa7d6cad469aed8218eadcb719c8495707275 [file] [log] [blame]
Yotam Harchol4d634682013-09-26 13:21:06 -07001package org.projectfloodlight.openflow.types;
2
3import org.projectfloodlight.openflow.types.IPAddress.IpVersion;
4
5public abstract class IPAddressWithMask<F extends IPAddress<F>> extends Masked<F> {
6
7 protected IPAddressWithMask(F value, F mask) {
8 super(value, mask);
9 }
10
11 public abstract IpVersion getIpVersion();
12
13 public static IPAddressWithMask<?> of(String ip) {
14 if (ip.indexOf('.') != -1)
15 return IPv4AddressWithMask.of(ip);
16 else if (ip.indexOf(':') != -1)
17 return IPv6AddressWithMask.of(ip);
18 else
19 throw new IllegalArgumentException("IP Address not well formed: " + ip);
20 }
21
22}