blob: 5b0e0f27e15fc408e1a661e2aca8dc0b54465c68 [file] [log] [blame]
xuzhang585f9052015-07-22 11:20:13 +08001/*
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 */
16package org.onosproject.app.vtnrsc;
17
18import java.util.Objects;
19
20import static com.google.common.base.Preconditions.checkNotNull;
21
22/**
23 * Immutable representation of a physicalnetwork 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 network id using the physicalnetwork.
37 *
38 * @param physicalnetwork network String
39 * @return physicalnetwork
40 */
41 public static PhysicalNetwork physicalNetwork(String physicalnetwork) {
42 return new PhysicalNetwork(physicalnetwork);
43 }
44
45 /**
46 *
47 * @return physicalnetwork
48 */
49 public String physicalnetwork() {
50 return physicalnetwork;
51 }
52
53 @Override
54 public int hashCode() {
55 return Objects.hash(physicalnetwork);
56 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof PhysicalNetwork) {
64 final PhysicalNetwork that = (PhysicalNetwork) obj;
65 return this.getClass() == that.getClass()
66 && Objects.equals(this.physicalnetwork,
67 that.physicalnetwork);
68 }
69 return false;
70 }
71
72 @Override
73 public String toString() {
74 return physicalnetwork;
75 }
76
77}