Update MRI projects for Aluminium
[bgpcep.git] / graph / graph-api / src / main / java / org / opendaylight / graph / ConnectedGraph.java
1 /*
2  * Copyright (c) 2019 Orange.  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 package org.opendaylight.graph;
9
10 import java.util.List;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.EdgeKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey;
20
21 /**
22  * Connected Graph class is the connected version of the Graph class from the graph yang model.
23  *
24  * <p>
25  * Connected Graph is composed by Connected Vertex, Connected Edges and Prefix. It models Unidirectional Connected
26  * Graph (see graph theory). So, Edge and Connected Edge are unidirectional, thus to connect bi-directionally 2 vertices
27  * Va and Vb, it is necessary to setup 2 edges: Va to Vb and Vb to Va.
28  * <pre>
29  * {@code
30  *        --------------     ---------------------------    --------------
31  *        | Connected  |---->| Connected Edge Va to Vb |--->| Connected  |
32  *   ---->|  Vertex    |     ---------------------------    |  Vertex    |---->
33  *        |            |                                    |            |
34  *        | - Key (Va) |                                    | - Key (Vb) |
35  *   <----| - Vertex   |     ---------------------------    | - Vertex   |<----
36  *        |            |<----| Connected Edge Vb to Va |<---|            |
37  *        --------------     ---------------------------    --------------
38  * }
39  * </pre>
40  *
41  * @author Olivier Dugeon
42  * @author Philippe Niger
43  */
44 public interface ConnectedGraph {
45
46     /**
47      * Returns the Graph associated to this Connected Graph.
48      *
49      * @return Graph
50      */
51     Graph getGraph();
52
53     /**
54      * Returns the list of Connected Vertices that form this graph.
55      *
56      * @return list of Connected Vertices
57      */
58     List<ConnectedVertex> getVertices();
59
60     /**
61      * Returns the Vertex associated to the given key.
62      *
63      * @param key Unique Vertex Identifier
64      * @return Vertex or null if there is no Vertex associated to the given key in this graph
65      */
66     ConnectedVertex getConnectedVertex(@NonNull Long key);
67
68     /**
69      * Returns the Vertex associated to the given IP address.
70      *
71      * @param address IP address of the Loopback of the Vertex
72      *
73      * @return Vertex or null if there is no Vertex associated to the given IP address in this graph
74      */
75     ConnectedVertex getConnectedVertex(IpAddress address);
76
77     /**
78      * Add Vertex in the Connected Graph. This action will automatically create the associated Connected Vertex and
79      * update the Graph in the DataStore.
80      *
81      * @param vertex Vertex to be added
82      *
83      * @return Connected Vertex associated to the given Vertex
84      */
85     ConnectedVertex addVertex(Vertex vertex);
86
87     /**
88      * Remove the Vertex in the Connected Graph. This action will automatically remove the associated Connected Vertex
89      * and update the Graph in the DataStore.
90      *
91      * @param vertexKey Unique Vertex Identifier
92      */
93     void deleteVertex(VertexKey vertexKey);
94
95     /**
96      * Returns the number of Vertices in the graph.
97      *
98      * @return number of vertices
99      */
100     int getVerticesSize();
101
102     /**
103      * Returns the list of Connected Edges that form this graph.
104      *
105      * @return list of Connected Edges
106      */
107     List<ConnectedEdge> getEdges();
108
109     /**
110      * Returns the Edge associated to the given key.
111      *
112      * @param key Unique Edge Identifier
113      * @return Edge or null if there is no Edge associated to the given key in this graph
114      */
115     ConnectedEdge getConnectedEdge(@NonNull Long key);
116
117     /**
118      * Returns the Edge associated to the given IP address.
119      *
120      * @param address IP address of the Edge
121      *
122      * @return Edge or null if there is no Edge associated to the given IP address in this graph
123      */
124     ConnectedEdge getConnectedEdge(IpAddress address);
125
126     /**
127      * Add Edge in the Connected Graph. This action will automatically create the associated Connected Edge and
128      * update the Graph in the DataStore.
129      *
130      * @param edge Edge to be added
131      *
132      * @return Connected Edge associated to the given Edge
133      */
134     ConnectedEdge addEdge(Edge edge);
135
136     /**
137      * Remove the Edge in the Connected Graph. This action will automatically remove the associated Connected Edge
138      * and update the Graph in the DataStore.
139      *
140      * @param edgeKey Unique Edge Identifier
141      */
142     void deleteEdge(EdgeKey edgeKey);
143
144     /**
145      * Returns the number of Edges in the graph.
146      *
147      * @return number of edges
148      */
149     int getEdgesSize();
150
151     /**
152      * Returns the list of Prefix that are stored in this graph.
153      *
154      * @return list of Prefix
155      */
156     List<Prefix> getPrefixes();
157
158     /**
159      * Returns the Prefix associated to the given IP prefix.
160      *
161      * @param ippfx IPv4 or IPv6 prefix
162      *
163      * @return Prefix that match the given IPv4 or IPv6 prefix
164      */
165     Prefix getPrefix(IpPrefix ippfx);
166
167     /**
168      * Add Prefix in the Connected Graph. This action will automatically update the Graph in the DataStore.
169      *
170      * @param prefix Prefix to be added
171      *
172      */
173     void addPrefix(Prefix prefix);
174
175     /**
176      * Remove the Prefix in the Connected Graph. This action will automatically update the Graph in the DataStore.
177      *
178      * @param ippfx IPv4 or IPv6 prefix
179      */
180     void deletePrefix(IpPrefix ippfx);
181
182     /**
183      * Clear the Connected Graph by removing all Vertices, Edges and Prefixes. This also remove the associated Graph
184      * in the Datastore.
185      *
186      */
187     void clear();
188
189     /**
190      * Returns the summary of the graph characteristics: number of Vertices, Edges and Prefix.
191      *
192      * @return characteristics of the Graph as a string
193      */
194     String getSummary();
195
196 }