1 package org.opendaylight.lispflowmapping.type.lisp.address;
3 import java.net.InetAddress;
4 import java.net.UnknownHostException;
5 import java.nio.ByteBuffer;
7 import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
9 public abstract class LispIPAddress extends LispAddress{
11 protected InetAddress address;
13 protected LispIPAddress(InetAddress address, AddressFamilyNumberEnum afi) {
15 this.address = address;
18 protected LispIPAddress(int address, AddressFamilyNumberEnum afi) {
21 this.address = InetAddress.getByAddress(ByteBuffer.allocate(4).putInt(address).array());
22 } catch (UnknownHostException e) {
23 // TODO Auto-generated catch block
28 protected LispIPAddress(byte[] address, AddressFamilyNumberEnum afi) {
32 this.address = InetAddress.getByAddress(address);
33 } catch (UnknownHostException e) {
34 // TODO Auto-generated catch block
39 protected LispIPAddress(String name, AddressFamilyNumberEnum afi) {
42 this.address = InetAddress.getByName(name);
43 } catch (UnknownHostException e) {
44 // TODO Auto-generated catch block
49 public InetAddress getAddress() {
55 public int hashCode() {
57 int result = super.hashCode();
58 result = prime * result + ((address == null) ? 0 : address.hashCode());
63 public boolean equals(Object obj) {
66 if (!super.equals(obj))
68 if (getClass() != obj.getClass())
70 LispIPAddress other = (LispIPAddress) obj;
71 if (address == null) {
72 if (other.address != null)
74 } else if (!address.equals(other.address))
80 public String toString() {
81 return address.getHostAddress();