blob: bf7de5740bb36b699f77e963443cbdf0c77a687d [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
Thomas Vachuska52f2cd12018-11-08 21:20:04 -080018import org.onosproject.net.TenantId;
19
Thomas Vachuska33979fd2015-07-31 11:41:14 -070020import java.util.Objects;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
23
24/**
25 * Default implementation of the virtual network descriptor.
26 */
Brian Stanke0e5c94e2016-03-08 11:20:04 -050027public final class DefaultVirtualNetwork implements VirtualNetwork {
Thomas Vachuska33979fd2015-07-31 11:41:14 -070028
29 private final NetworkId id;
30 private final TenantId tenantId;
31
32 /**
33 * Creates a new virtual network descriptor.
34 *
35 * @param id network identifier
36 * @param tenantId tenant identifier
37 */
38 public DefaultVirtualNetwork(NetworkId id, TenantId tenantId) {
39 this.id = id;
40 this.tenantId = tenantId;
41 }
42
43 @Override
44 public NetworkId id() {
45 return id;
46 }
47
48 @Override
49 public TenantId tenantId() {
50 return tenantId;
51 }
52
53 @Override
54 public int hashCode() {
55 return Objects.hash(id, tenantId);
56 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof DefaultVirtualNetwork) {
64 DefaultVirtualNetwork that = (DefaultVirtualNetwork) obj;
65 return Objects.equals(this.id, that.id)
66 && Objects.equals(this.tenantId, that.tenantId);
67 }
68 return false;
69 }
70
71 @Override
72 public String toString() {
73 return toStringHelper(this)
74 .add("id", id)
75 .add("tenantId", tenantId)
76 .toString();
77 }
78}