Add mod/runtimeapi
[dcaegen2/platform.git] / mod / runtimeapi / runtime-core / src / main / java / org / onap / dcae / runtime / core / FlowGraph.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  */
18 package org.onap.dcae.runtime.core;
19
20 import com.google.common.graph.MutableNetwork;
21 import com.google.common.graph.NetworkBuilder;
22
23 import java.util.Set;
24
25 public class FlowGraph<Node,Edge> {
26     private  String id;
27     private  String name;
28     private  boolean isMain;
29     private  String description;
30     private MutableNetwork<Node,Edge> mutableNetwork;
31
32     public FlowGraph(String id, String name, boolean isMain, String description) {
33         this.id = id;
34         this.name = name;
35         this.isMain = isMain;
36         this.description = description;
37         this.mutableNetwork = NetworkBuilder.directed().build();
38     }
39
40     public String getId() {
41         return id;
42     }
43
44     public void setId(String id) {
45         this.id = id;
46     }
47
48     public String getName() {
49         return name;
50     }
51
52     public void setName(String name) {
53         this.name = name;
54     }
55
56     public boolean isMain() {
57         return isMain;
58     }
59
60     public void setMain(boolean main) {
61         isMain = main;
62     }
63
64     public String getDescription() {
65         return description;
66     }
67
68     public void setDescription(String description) {
69         this.description = description;
70     }
71
72     public void addNode(Node node) {
73         mutableNetwork.addNode(node);
74     }
75
76     public int getNodeSize() {
77         return mutableNetwork.nodes().size();
78     }
79
80     public Set<Node> getNodes() {
81         return mutableNetwork.nodes();
82     }
83
84     public Set<Edge> getEdges() {
85         return mutableNetwork.edges();
86     }
87
88     public void addEdge(Node node_1, Node node_2, Edge edge) {
89         mutableNetwork.addEdge(node_1,node_2,edge);
90     }
91
92     public int getEdgeSize() {
93         return mutableNetwork.edges().size();
94     }
95
96     public Edge getEdge(Node node_1, Node node_2) {
97         return mutableNetwork.edgeConnecting(node_1,node_2).get();
98     }
99
100     public void removeNode(Node node_1) {
101         mutableNetwork.removeNode(node_1);
102     }
103
104     public void removeEdge(Edge edge_1) {
105         mutableNetwork.removeEdge(edge_1);
106     }
107
108 }