2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.dao.graph.datatype;
23 import java.util.HashMap;
26 public class GraphRelation extends GraphElement {
28 private RelationEndPoint from;
29 private RelationEndPoint to;
31 private Map<String, Object> properties;
33 public GraphRelation() {
34 super(GraphElementTypeEnum.Relationship);
35 properties = new HashMap<>();
38 public GraphRelation(String type) {
39 super(GraphElementTypeEnum.Relationship);
40 properties = new HashMap<>();
44 public RelationEndPoint getFrom() {
48 public void setFrom(RelationEndPoint from) {
52 public RelationEndPoint getTo() {
56 public void setTo(RelationEndPoint to) {
60 public String getType() {
64 public void setType(String type) {
68 public void addProperty(String property, Object value) {
69 if (property != null && !property.isEmpty() && value != null) {
70 properties.put(property, value);
74 public void addPropertis(Map<String, Object> props) {
76 properties.putAll(props);
80 public void overwritePropertis(Map<String, Object> props) {
84 public Object getProperty(String property) {
85 return properties.get(property);
89 public Map<String, Object> toGraphMap() {
94 public String toString() {
95 return "GraphRelation [from=" + from + ", to=" + to + ", type=" + type + ", properties=" + properties + "]";
99 public int hashCode() {
100 final int prime = 31;
102 result = prime * result + ((from == null) ? 0 : from.hashCode());
103 result = prime * result + ((properties == null) ? 0 : properties.hashCode());
104 result = prime * result + ((to == null) ? 0 : to.hashCode());
105 result = prime * result + ((type == null) ? 0 : type.hashCode());