blob: d2d9a0c8a686f0900efb8fd9f1df7d7feaf4e8c8 [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 java.util.Objects;
19
20import static com.google.common.base.Preconditions.checkNotNull;
21
22/**
23 * Immutable representation of a physical network identity.
24 */
25public final class PhysicalNetwork {
26
27 private final String physicalNetwork;
28
29 // Public construction is prohibited
30 private PhysicalNetwork(String physicalNetwork) {
31 checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
32 this.physicalNetwork = physicalNetwork;
33 }
34
35 /**
36 * Creates a PhysicalNetwork object.
37 *
38 * @param physicalNetwork physical network
39 * @return physical network
40 */
41 public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
42 return new PhysicalNetwork(physicalNetwork);
43 }
44
45 /**
46 * Returns a physicalNetwork.
47 *
48 * @return physical network
49 */
50 public String physicalNetwork() {
51 return physicalNetwork;
52 }
53
54 @Override
55 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070056 return physicalNetwork.hashCode();
Sho SHIMIZUb2b2d982015-09-11 15:35:06 -070057 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (obj instanceof PhysicalNetwork) {
65 final PhysicalNetwork that = (PhysicalNetwork) obj;
66 return this.getClass() == that.getClass()
67 && Objects.equals(this.physicalNetwork,
68 that.physicalNetwork);
69 }
70 return false;
71 }
72
73 @Override
74 public String toString() {
75 return physicalNetwork;
76 }
77
78}