blob: 580dd2a38d7536ce2b5fe4eae5c6d7ca84cd85df [file] [log] [blame]
Ramon Casellas247a68f2019-01-18 13:36:14 +01001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.odtn;
18
19import org.onosproject.net.ConnectPoint;
20import java.util.Objects;
21
22/**
23 * Configuration related to a TAPI Connectivity.
24 *
25 * At this point, the class only conveys the
26 * Connectivity service uuid, the ConnectPoints
27 * obtained from the TAPI SIP and a boolean that
28 * means setup or release. Additional attributes
29 * may be needed when we further parse the TAPI
30 * request, this class will grow accordingly.
31 */
32public final class TapiConnectivityConfig {
33
34 private final String uuid;
35 private final ConnectPoint left;
36 private final ConnectPoint right;
37 private final boolean setup;
38
39
40 /**
41 * Constructor with the Connection uuid and endpoints.
42 *
43 * @param uuid - TAPI uuid of the connection.
44 * @param leftCp Left (ingress) ConnectPoint.
45 * @param rightCp Right (egress) ConnectPoint.
46 * @param setup True or false (setup or release).
47 */
48 public TapiConnectivityConfig(String uuid, ConnectPoint leftCp,
49 ConnectPoint rightCp, Boolean setup) {
50 this.uuid = uuid;
51 this.left = leftCp;
52 this.right = rightCp;
53 this.setup = setup;
54 }
55
56 /**
57 * Get the UUID associated to this TAPI connectivity rquest.
58 *
59 * @return the UUID.
60 */
61 public String uuid() {
62 return uuid;
63 }
64
65
66 /**
67 * Get the left (first) ConnectPoint of the request.
68 * The left CP corresponds to the first endpoint in the TAPI
69 * request.
70 *
71 * @return the connect point.
72 */
73 public ConnectPoint leftCp() {
74 return left;
75 }
76
77
78 /**
79 * Get the right (second) ConnectPoint of the request.
80 * The right CP corresponds to the second endpoint in the TAPI
81 * request.
82 *
83 * @return the connect point.
84 */
85 public ConnectPoint rightCp() {
86 return right;
87 }
88
89 /**
90 * Check if the request is for a setup or release.
91 *
92 * @return True for a setup request, False otherwise.
93 */
94 public Boolean isSetup() {
95 return setup;
96 }
97
98
99 /**
100 * Equals comparison.
101 *
102 * @return True if this:Object.equals(o)
103 */
104 @Override
105 public boolean equals(Object o) {
106 if (this == o) {
107 return true;
108 }
109 if (!(o instanceof TapiConnectivityConfig)) {
110 return false;
111 }
112 TapiConnectivityConfig that = (TapiConnectivityConfig) o;
113 return Objects.equals(uuid, that.uuid) &&
114 Objects.equals(left, that.left) &&
115 Objects.equals(right, that.right) &&
116 Objects.equals(setup, that.setup);
117 }
118
119
120 /**
121 * Get the hashcode for the TapiConnectivityConfig Object.
122 *
123 * @return the result of Objects.hash
124 */
125 @Override
126 public int hashCode() {
127 return Objects.hash(uuid, left, right, setup);
128 }
129}