Migrate Spike code to ONAP
[aai/spike.git] / src / main / java / org / onap / aai / spike / schema / Relationship.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.spike.schema;
22
23 import java.util.HashMap;
24 import java.util.Map;
25 import javax.xml.bind.annotation.XmlElement;
26 import javax.xml.bind.annotation.XmlRootElement;
27 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
28 import com.google.gson.annotations.SerializedName;
29
30
31 /**
32  * This class represents a relationship instance that can be used for marshalling and unmarshalling
33  * to/from a model compliant representation.
34  */
35 @XmlRootElement
36 public class Relationship {
37
38     /** Unique identifier for this relationship. */
39     private String id;
40
41     /** Relationship type. */
42     private String type;
43
44     /** The source vertex for this edge. */
45     @SerializedName("source-node-type")
46     private String sourceNodeType;
47
48     /** The target vertex for this edge. */
49     @SerializedName("target-node-type")
50     private String targetNodeType;
51
52     /** The properties assigned to this edge. */
53     private Map<String, Object> properties = new HashMap<String, Object>();
54
55
56     public String getId() {
57         return id;
58     }
59
60     public void setId(String id) {
61         this.id = id;
62     }
63
64     public String getType() {
65         return type;
66     }
67
68     public void setType(String type) {
69         this.type = type;
70     }
71
72     public String getSourceNodeType() {
73         return sourceNodeType;
74     }
75
76     @XmlElement(name = "source-node-type")
77     public void setSourceNodeType(String sourceNodeType) {
78         this.sourceNodeType = sourceNodeType;
79     }
80
81     public String getTargetNodeType() {
82         return targetNodeType;
83     }
84
85     @XmlElement(name = "target-node-type")
86     public void setTargetNodeType(String targetNodeType) {
87         this.targetNodeType = targetNodeType;
88     }
89
90     @XmlJavaTypeAdapter(MapAdapter.class)
91     public Map<String, Object> getProperties() {
92         return properties;
93     }
94
95     public void setProperties(Map<String, Object> properties) {
96         this.properties = properties;
97     }
98
99     public void setProperty(String key, Object property) {
100         properties.put(key, property);
101     }
102 }