blob: 4a7605fc37070730a8a6350112b9cf212a1754a1 [file] [log] [blame]
Daniel Park5df65182016-01-09 00:12:03 +09001/*
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 */
16package org.onosproject.openstackswitching;
17
18import org.onlab.packet.Ip4Address;
19import org.onosproject.net.DeviceId;
20
21import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Contains OpenstackPort Information.
25 */
26public 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
70 public Builder setVNI(long vni) {
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}