7bfdf290a9f5240d6a16799f6bc1baad54533524
[onosfw.git] /
1 /*
2  * Copyright 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  */
16 package org.onosproject.openstackswitching;
17
18 import static com.google.common.base.Preconditions.checkNotNull;
19
20
21 /**
22  * Represents the network information given by Neutron.
23  */
24 public final class OpenstackNetwork {
25
26     private String name;
27     private String tenantId;
28     private String segmentId;
29     private String id;
30     private NetworkType networkType;
31
32     public enum NetworkType {
33         /**
34          * Currently only VXLAN moded is supported.
35          */
36         VXLAN,
37         VLAN,
38         STT,
39         LOCAL
40     }
41
42     /**
43      * Returns the builder object of the OpenstackNetwork class.
44      *
45      * @return OpenstackNetwork builder object
46      */
47     public static OpenstackNetwork.Builder builder() {
48         return new Builder();
49     }
50
51     private OpenstackNetwork(String name, String tenantId, String id, String sid,
52                              NetworkType type) {
53         this.name = checkNotNull(name);
54         this.tenantId = checkNotNull(tenantId);
55         this.segmentId = checkNotNull(sid);
56         this.id = checkNotNull(id);
57         this.networkType = type;
58     }
59
60     public String name() {
61         return this.name;
62     }
63
64     public String tenantId() {
65         return this.tenantId;
66     }
67
68     public String id() {
69         return this.id;
70     }
71
72     public String segmentId() {
73         return this.segmentId;
74     }
75
76     public NetworkType networkType() {
77         return this.networkType;
78     }
79
80     public static final class Builder {
81         private String name;
82         private String tenantId;
83         private String id;
84         private String sid;
85         private NetworkType networkType;
86
87         public Builder name(String name) {
88             this.name = name;
89
90             return this;
91         }
92
93         public Builder tenantId(String tenantId) {
94             this.tenantId = tenantId;
95
96             return this;
97         }
98
99         public Builder id(String id) {
100             this.id = id;
101
102             return this;
103         }
104
105         public Builder segmentId(String sid) {
106             this.sid = sid;
107
108             return this;
109         }
110
111         public Builder networkType(NetworkType type) {
112             this.networkType = type;
113
114             return this;
115         }
116
117         public OpenstackNetwork build() {
118             return new OpenstackNetwork(name, tenantId, id, sid, networkType);
119         }
120
121     }
122 }