sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 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 | */ |
sangho | 93447f1 | 2016-02-24 00:33:22 +0900 | [diff] [blame] | 16 | package org.onosproject.openstackinterface; |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 17 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | |
| 22 | /** |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 23 | * An OpenStack Neutron router interface model. |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 24 | */ |
| 25 | public 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 | /** |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 40 | * Returns router interface ID. |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 41 | * |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 42 | * @return router interface id |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 43 | */ |
| 44 | public String id() { |
| 45 | return id; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns tenant ID. |
| 50 | * |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 51 | * @return tenant id |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 52 | */ |
| 53 | public String tenantId() { |
| 54 | return tenantId; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns subnet ID. |
| 59 | * |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 60 | * @return subnet id |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 61 | */ |
| 62 | public String subnetId() { |
| 63 | return subnetId; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns port ID. |
| 68 | * |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 69 | * @return port id |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 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 | /** |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 99 | * Returns OpenStack router interface builder. |
| 100 | * |
| 101 | * @return openstack router interface builder |
| 102 | */ |
| 103 | public static Builder builder() { |
| 104 | return new Builder(); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * An OpenStack Router interface builder class. |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 109 | */ |
| 110 | public static final class Builder { |
Kyuhwi Choi | e2b37e3 | 2016-02-05 14:04:14 +0900 | [diff] [blame] | 111 | private String id; |
| 112 | private String tenantId; |
| 113 | private String subnetId; |
| 114 | private String portId; |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 115 | |
Kyuhwi Choi | e2b37e3 | 2016-02-05 14:04:14 +0900 | [diff] [blame] | 116 | /** |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 117 | * Sets router interface ID. |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 118 | * |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 119 | * @param id router interface id |
| 120 | * @return builder object |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 121 | */ |
| 122 | public Builder id(String id) { |
| 123 | this.id = id; |
| 124 | return this; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Sets tenant ID. |
| 129 | * |
| 130 | * @param tenantId tenant ID |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 131 | * @return builder object |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 132 | */ |
| 133 | public Builder tenantId(String tenantId) { |
| 134 | this.tenantId = tenantId; |
| 135 | return this; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Sets subnet ID. |
| 140 | * |
| 141 | * @param subnetId subnet ID |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 142 | * @return builder object |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 143 | */ |
| 144 | public Builder subnetId(String subnetId) { |
| 145 | this.subnetId = subnetId; |
| 146 | return this; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Sets port ID. |
| 151 | * |
| 152 | * @param portId port ID |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 153 | * @return builder object |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 154 | */ |
| 155 | public Builder portId(String portId) { |
| 156 | this.portId = portId; |
| 157 | return this; |
| 158 | } |
| 159 | |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 160 | /** |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 161 | * Builds an OpenStack router interface object. |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 162 | * |
Hyunsun Moon | b3eb84d | 2016-07-27 19:10:52 -0700 | [diff] [blame] | 163 | * @return openstack router interface object |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 164 | */ |
| 165 | public OpenstackRouterInterface build() { |
Kyuhwi Choi | e2b37e3 | 2016-02-05 14:04:14 +0900 | [diff] [blame] | 166 | return new OpenstackRouterInterface(checkNotNull(id), checkNotNull(tenantId), |
| 167 | checkNotNull(subnetId), checkNotNull(portId)); |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 168 | } |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 169 | } |
| 170 | } |