CNlucius | 5b2fff1 | 2015-08-20 14:13:46 +0800 | [diff] [blame] | 1 | /*
|
| 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 | */
|
| 16 | package org.onosproject.vtnrsc;
|
| 17 |
|
| 18 | import java.util.Objects;
|
| 19 |
|
| 20 | import static com.google.common.base.Preconditions.checkNotNull;
|
| 21 |
|
| 22 | /**
|
| 23 | * Immutable representation of a physical network identity.
|
| 24 | */
|
| 25 | public 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() {
|
| 56 | return Objects.hash(physicalNetwork);
|
| 57 | }
|
| 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 | }
|