blob: a42a700f6be0cdbf279c0f367d6bdbe0f72d8ebd [file] [log] [blame]
Phaneendra Mandaac636502015-10-26 22:28:09 +05301/*
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.vtnrsc;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.UUID;
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053022import java.util.Objects;
Phaneendra Mandaac636502015-10-26 22:28:09 +053023
24/**
25 * Representation of a Port Chain ID.
26 */
27public final class PortChainId {
28
29 private final UUID portChainId;
30
31 /**
32 * Private constructor for port chain id.
33 *
34 * @param id UUID id of port chain
35 */
36 private PortChainId(UUID id) {
37 checkNotNull(id, "Port chain id can not be null");
38 this.portChainId = id;
39 }
40
41 /**
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053042 * Returns newly created port chain id object.
Phaneendra Mandaac636502015-10-26 22:28:09 +053043 *
44 * @param id UUID of port chain
45 * @return object of port chain id
46 */
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053047 public static PortChainId of(UUID id) {
Phaneendra Mandaac636502015-10-26 22:28:09 +053048 return new PortChainId(id);
49 }
50
51 /**
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053052 * Returns newly created port chain id object.
Phaneendra Mandaac636502015-10-26 22:28:09 +053053 *
54 * @param id port chain id in string
55 * @return object of port chain id
56 */
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053057 public static PortChainId of(String id) {
Phaneendra Mandaac636502015-10-26 22:28:09 +053058 return new PortChainId(UUID.fromString(id));
59 }
60
61 /**
62 * Returns the value of port chain id.
63 *
64 * @return port chain id
65 */
66 public UUID value() {
67 return portChainId;
68 }
69
70 @Override
71 public boolean equals(Object obj) {
72 if (this == obj) {
73 return true;
74 }
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053075 if (obj instanceof PortChainId) {
76 final PortChainId other = (PortChainId) obj;
77 return Objects.equals(this.portChainId, other.portChainId);
Phaneendra Mandaac636502015-10-26 22:28:09 +053078 }
79 return false;
80 }
81
82 @Override
83 public int hashCode() {
84 return Objects.hashCode(this.portChainId);
85 }
86
87 @Override
88 public String toString() {
Mahesh Poojary Huaweia9feb6d2015-11-05 13:24:16 +053089 return toStringHelper(this).add("portChainId", portChainId).toString();
Phaneendra Mandaac636502015-10-26 22:28:09 +053090 }
91}