Basic AD-SAL inventory service
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / inventory / IPAddressNodeProperty.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
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
9 package org.opendaylight.lispflowmapping.implementation.inventory;
10
11 import java.net.InetAddress;
12
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
17
18 import org.opendaylight.controller.sal.core.Property;
19
20 @XmlRootElement
21 @XmlAccessorType(XmlAccessType.NONE)
22 public class IPAddressNodeProperty extends Property implements Cloneable {
23     private static final long serialVersionUID = 1L;
24     @XmlElement(name="value")
25     private final InetAddress address;
26     public static final String name = "IPAddress";
27
28     /*
29      * Private constructor used for JAXB mapping
30      */
31     private IPAddressNodeProperty() {
32         super(name);
33         this.address = null;
34     }
35
36     public IPAddressNodeProperty(InetAddress address) {
37         super(name);
38         this.address = address;
39     }
40
41     @Override
42     public String getStringValue() {
43         if (address == null) return null;
44         return this.address.getHostAddress();
45     }
46
47     @Override
48     public Property clone() {
49         return new IPAddressNodeProperty(this.address);
50     }
51
52     public InetAddress getAddress() {
53         return address;
54     }
55 }