blob: 8271cd8dfd7ef2cedb022006bc0e1cbc424e046d [file] [log] [blame]
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -07003 *
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.vtnrsc;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21
22/**
23 * Default implementation of TenantNetwork interface.
24 */
25public final class DefaultTenantNetwork implements TenantNetwork {
26 private final TenantNetworkId id;
27 private final String name;
28 private final boolean adminStateUp;
29 private final State state;
30 private final boolean shared;
31 private final Type type;
32 private final TenantId tenantId;
33 private final boolean routerExternal;
34 private final PhysicalNetwork physicalNetwork;
35 private final SegmentationId segmentationId;
36
37 /**
38 * Creates a neutronNetwork element attributed to the specified provider.
39 *
40 * @param id network identifier
41 * @param name the network name
42 * @param adminStateUp administrative state of the network
43 * @param state the network state
44 * @param shared indicates whether this network is shared across all
45 * tenants, By default, only administrative user can change this
46 * value
47 * @param tenantId tenant identifier
48 * @param routerExternal network routerExternal
49 * @param type the network type
50 * @param physicalNetwork physicalNetwork identifier
51 * @param segmentationId segmentation identifier
52 */
53 public DefaultTenantNetwork(TenantNetworkId id, String name,
54 boolean adminStateUp, State state,
55 boolean shared, TenantId tenantId,
56 boolean routerExternal, Type type,
57 PhysicalNetwork physicalNetwork,
58 SegmentationId segmentationId) {
59 this.id = id;
60 this.name = name;
61 this.adminStateUp = adminStateUp;
62 this.state = state;
63 this.shared = shared;
64 this.type = type;
65 this.tenantId = tenantId;
66 this.routerExternal = routerExternal;
67 this.physicalNetwork = physicalNetwork;
68 this.segmentationId = segmentationId;
69 }
70
71 @Override
72 public TenantNetworkId id() {
73 return id;
74 }
75
76 @Override
77 public String name() {
78 return name;
79 }
80
81 @Override
82 public boolean adminStateUp() {
83 return adminStateUp;
84 }
85
86 @Override
87 public State state() {
88 return state;
89 }
90
91 @Override
92 public boolean shared() {
93 return shared;
94 }
95
96 @Override
97 public TenantId tenantId() {
98 return tenantId;
99 }
100
101 @Override
102 public boolean routerExternal() {
103 return routerExternal;
104 }
105
106 @Override
107 public Type type() {
108 return type;
109 }
110
111 @Override
112 public PhysicalNetwork physicalNetwork() {
113 return physicalNetwork;
114 }
115
116 @Override
117 public SegmentationId segmentationId() {
118 return segmentationId;
119 }
120
121 @Override
122 public int hashCode() {
123 return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
124 routerExternal, type, physicalNetwork,
125 segmentationId);
126 }
127
128 @Override
129 public boolean equals(Object obj) {
130 if (this == obj) {
131 return true;
132 }
133 if (obj instanceof DefaultTenantNetwork) {
134 final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
135 return Objects.equals(this.id, that.id)
136 && Objects.equals(this.name, that.name)
137 && Objects.equals(this.adminStateUp, that.adminStateUp)
138 && Objects.equals(this.state, that.state)
139 && Objects.equals(this.shared, that.shared)
140 && Objects.equals(this.tenantId, that.tenantId)
141 && Objects.equals(this.routerExternal, that.routerExternal)
142 && Objects.equals(this.type, that.type)
143 && Objects.equals(this.physicalNetwork,
144 that.physicalNetwork)
145 && Objects.equals(this.segmentationId, that.segmentationId);
146 }
147 return false;
148 }
149
150 @Override
151 public String toString() {
152 return toStringHelper(this).add("id", id).add("name", name)
153 .add("adminStateUp", adminStateUp).add("state", state)
154 .add("shared", shared).add("tenantId", tenantId)
155 .add("routeExternal", routerExternal).add("type", type)
156 .add("physicalNetwork", physicalNetwork)
157 .add("segmentationId", segmentationId).toString();
158 }
159
160}