Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014-2015 Open Networking Laboratory |
| 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 | */ |
Jian Li | 7f256f5 | 2016-01-24 15:08:05 -0800 | [diff] [blame] | 16 | package org.onosproject.openstackswitching.impl; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.Ip4Address; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | /** |
| 24 | * Contains OpenstackPort Information. |
| 25 | */ |
| 26 | public final class OpenstackPortInfo { |
| 27 | |
| 28 | private final Ip4Address hostIp; |
| 29 | private final DeviceId deviceId; |
| 30 | private final long vni; |
| 31 | |
| 32 | public OpenstackPortInfo(Ip4Address hostIp, DeviceId deviceId, |
| 33 | long vni) { |
| 34 | this.hostIp = hostIp; |
| 35 | this.deviceId = deviceId; |
| 36 | this.vni = vni; |
| 37 | } |
| 38 | |
| 39 | public Ip4Address ip() { |
| 40 | return hostIp; |
| 41 | } |
| 42 | |
| 43 | public DeviceId deviceId() { |
| 44 | return deviceId; |
| 45 | } |
| 46 | |
| 47 | public long vni() { |
| 48 | return vni; |
| 49 | } |
| 50 | |
| 51 | public static OpenstackPortInfo.Builder builder() { |
| 52 | return new Builder(); |
| 53 | } |
| 54 | |
| 55 | public static final class Builder { |
| 56 | private Ip4Address hostIp; |
| 57 | private DeviceId deviceId; |
| 58 | private long vni; |
| 59 | |
| 60 | public Builder setHostIp(Ip4Address hostIp) { |
| 61 | this.hostIp = checkNotNull(hostIp, "hostIp cannot be null"); |
| 62 | return this; |
| 63 | } |
| 64 | |
| 65 | public Builder setDeviceId(DeviceId deviceId) { |
| 66 | this.deviceId = checkNotNull(deviceId, "deviceId cannot be null"); |
| 67 | return this; |
| 68 | } |
| 69 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame^] | 70 | public Builder setVni(long vni) { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 71 | this.vni = checkNotNull(vni, "vni cannot be null"); |
| 72 | return this; |
| 73 | } |
| 74 | public OpenstackPortInfo build() { |
| 75 | return new OpenstackPortInfo(this); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | private OpenstackPortInfo(Builder builder) { |
| 80 | hostIp = builder.hostIp; |
| 81 | deviceId = builder.deviceId; |
| 82 | vni = builder.vni; |
| 83 | } |
| 84 | } |