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 | /** |
| 23 | * An Openstack Neutron Router Interface Model. |
| 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 | /** |
| 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 Choi | e2b37e3 | 2016-02-05 14:04:14 +0900 | [diff] [blame] | 102 | private String id; |
| 103 | private String tenantId; |
| 104 | private String subnetId; |
| 105 | private String portId; |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 106 | |
Kyuhwi Choi | e2b37e3 | 2016-02-05 14:04:14 +0900 | [diff] [blame] | 107 | /** |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 108 | * 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 | |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 151 | /** |
| 152 | * Builds an Openstack Router Interface object. |
| 153 | * |
| 154 | * @return OpenstackRouterInterface object |
| 155 | */ |
| 156 | public OpenstackRouterInterface build() { |
Kyuhwi Choi | e2b37e3 | 2016-02-05 14:04:14 +0900 | [diff] [blame] | 157 | return new OpenstackRouterInterface(checkNotNull(id), checkNotNull(tenantId), |
| 158 | checkNotNull(subnetId), checkNotNull(portId)); |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | } |
| 162 | } |