blob: 5bb3ce03a1ee0db8e68e5ce3cc00fa7c8762df8c [file] [log] [blame]
Thomas Vachuska33979fd2015-07-31 11:41:14 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska33979fd2015-07-31 11:41:14 -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.incubator.net.virtual;
17
18import java.util.Objects;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22/**
23 * Default implementation of the virtual network descriptor.
24 */
Brian Stanke0e5c94e2016-03-08 11:20:04 -050025public final class DefaultVirtualNetwork implements VirtualNetwork {
Thomas Vachuska33979fd2015-07-31 11:41:14 -070026
27 private final NetworkId id;
28 private final TenantId tenantId;
29
30 /**
31 * Creates a new virtual network descriptor.
32 *
33 * @param id network identifier
34 * @param tenantId tenant identifier
35 */
36 public DefaultVirtualNetwork(NetworkId id, TenantId tenantId) {
37 this.id = id;
38 this.tenantId = tenantId;
39 }
40
41 @Override
42 public NetworkId id() {
43 return id;
44 }
45
46 @Override
47 public TenantId tenantId() {
48 return tenantId;
49 }
50
51 @Override
52 public int hashCode() {
53 return Objects.hash(id, tenantId);
54 }
55
56 @Override
57 public boolean equals(Object obj) {
58 if (this == obj) {
59 return true;
60 }
61 if (obj instanceof DefaultVirtualNetwork) {
62 DefaultVirtualNetwork that = (DefaultVirtualNetwork) obj;
63 return Objects.equals(this.id, that.id)
64 && Objects.equals(this.tenantId, that.tenantId);
65 }
66 return false;
67 }
68
69 @Override
70 public String toString() {
71 return toStringHelper(this)
72 .add("id", id)
73 .add("tenantId", tenantId)
74 .toString();
75 }
76}