3caa2a19b57a0e25dfc997d00c9ab8de4de90232
[ovsdb.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / plugin / IPAddressProperty.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Madhu Venugopal, Brent Salisbury
9  */
10
11 package org.opendaylight.ovsdb.plugin;
12 import java.net.InetAddress;
13
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 import org.opendaylight.controller.sal.core.Property;
20
21 @XmlRootElement
22 @XmlAccessorType(XmlAccessType.NONE)
23 public class IPAddressProperty extends Property implements Cloneable {
24     private static final long serialVersionUID = 1L;
25     @XmlElement(name="value")
26     private final InetAddress address;
27     public static final String name = "IPAddress";
28
29     /*
30      * Private constructor used for JAXB mapping
31      */
32     private IPAddressProperty() {
33         super(name);
34         this.address = null;
35     }
36
37     public IPAddressProperty(InetAddress address) {
38         super(name);
39         this.address = address;
40     }
41
42     @Override
43     public String getStringValue() {
44         if (address == null) return null;
45         return this.address.getHostAddress();
46     }
47
48     @Override
49     public Property clone() {
50         return new IPAddressProperty(this.address);
51     }
52
53     public InetAddress getAddress() {
54         return address;
55     }
56 }