Yotam Harchol | 4d63468 | 2013-09-26 13:21:06 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.types; |
| 2 | |
| 3 | import org.projectfloodlight.openflow.types.IPAddress.IpVersion; |
| 4 | |
| 5 | public 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 | } |