blob: 797c9a8b71e14b0faf12088e90bf071c6f86f04c [file] [log] [blame]
sangho0c2a3da2016-02-16 13:39:07 +09001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
sangho0c2a3da2016-02-16 13:39:07 +09003 *
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 */
sangho93447f12016-02-24 00:33:22 +090016package org.onosproject.openstackinterface;
sangho0c2a3da2016-02-16 13:39:07 +090017
18import java.util.Objects;
19
20import static com.google.common.base.Preconditions.checkNotNull;
21
22/**
23 * An Openstack Neutron Router Interface Model.
24 */
25public final class OpenstackRouterInterface {
26 private final String id;
27 private final String tenantId;
28 private final String subnetId;
29 private final String portId;
30
31 private OpenstackRouterInterface(String id, String tenantId,
32 String subnetId, String portId) {
33 this.id = checkNotNull(id);
34 this.tenantId = checkNotNull(tenantId);
35 this.subnetId = checkNotNull(subnetId);
36 this.portId = checkNotNull(portId);
37 }
38
39 /**
40 * Returns Router Interface ID.
41 *
42 * @return router interface ID
43 */
44 public String id() {
45 return id;
46 }
47
48 /**
49 * Returns tenant ID.
50 *
51 * @return tenant ID
52 */
53 public String tenantId() {
54 return tenantId;
55 }
56
57 /**
58 * Returns subnet ID.
59 *
60 * @return subnet ID
61 */
62 public String subnetId() {
63 return subnetId;
64 }
65
66 /**
67 * Returns port ID.
68 *
69 * @return port ID
70 */
71 public String portId() {
72 return portId;
73 }
74
75 @Override
76 public boolean equals(Object o) {
77 if (this == o) {
78 return true;
79 }
80
81 if (o instanceof OpenstackRouterInterface) {
82 OpenstackRouterInterface that = (OpenstackRouterInterface) o;
83
84 return this.id.equals(that.id) &&
85 this.portId.equals(that.portId) &&
86 this.subnetId.equals(that.subnetId) &&
87 this.tenantId.equals(that.tenantId);
88 }
89
90 return false;
91 }
92
93 @Override
94 public int hashCode() {
95 return Objects.hash(id, portId, subnetId, tenantId);
96 }
97
98 /**
99 * An Openstack Router Interface Builder class.
100 */
101 public static final class Builder {
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900102 private String id;
103 private String tenantId;
104 private String subnetId;
105 private String portId;
sangho0c2a3da2016-02-16 13:39:07 +0900106
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900107 /**
sangho0c2a3da2016-02-16 13:39:07 +0900108 * Sets Router Interface ID.
109 *
110 * @param id router interface ID
111 * @return Builder object
112 */
113 public Builder id(String id) {
114 this.id = id;
115 return this;
116 }
117
118 /**
119 * Sets tenant ID.
120 *
121 * @param tenantId tenant ID
122 * @return Builder object
123 */
124 public Builder tenantId(String tenantId) {
125 this.tenantId = tenantId;
126 return this;
127 }
128
129 /**
130 * Sets subnet ID.
131 *
132 * @param subnetId subnet ID
133 * @return Builder object
134 */
135 public Builder subnetId(String subnetId) {
136 this.subnetId = subnetId;
137 return this;
138 }
139
140 /**
141 * Sets port ID.
142 *
143 * @param portId port ID
144 * @return Builder object
145 */
146 public Builder portId(String portId) {
147 this.portId = portId;
148 return this;
149 }
150
sangho0c2a3da2016-02-16 13:39:07 +0900151 /**
152 * Builds an Openstack Router Interface object.
153 *
154 * @return OpenstackRouterInterface object
155 */
156 public OpenstackRouterInterface build() {
Kyuhwi Choie2b37e32016-02-05 14:04:14 +0900157 return new OpenstackRouterInterface(checkNotNull(id), checkNotNull(tenantId),
158 checkNotNull(subnetId), checkNotNull(portId));
sangho0c2a3da2016-02-16 13:39:07 +0900159 }
160
161 }
162}