blob: e14e95a05fb2e7cce1b9c16ba1e746295b318e8d [file] [log] [blame]
Phaneendra Manda635f6212015-10-26 18:27:41 +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;
Phaneendra Manda635f6212015-10-26 18:27:41 +053019
20import java.util.UUID;
Mahesh Poojary Se74f9012015-10-29 12:22:47 +053021import java.util.Objects;
Phaneendra Manda635f6212015-10-26 18:27:41 +053022
23/**
24 * Representation of a Port Pair ID.
25 */
26public final class PortPairId {
27
28 private final UUID portPairId;
29
30 /**
31 * Private constructor for port pair id.
32 *
33 * @param id UUID id of port pair
34 */
Mahesh Poojary Se74f9012015-10-29 12:22:47 +053035 private PortPairId(final UUID id) {
Phaneendra Manda635f6212015-10-26 18:27:41 +053036 this.portPairId = id;
37 }
38
39 /**
40 * Constructor to create port pair id from UUID.
41 *
42 * @param id UUID of port pair id
43 * @return object of port pair id
44 */
Mahesh Poojary Se74f9012015-10-29 12:22:47 +053045 public static PortPairId portPairId(final UUID id) {
Phaneendra Manda635f6212015-10-26 18:27:41 +053046 return new PortPairId(id);
47 }
48
49 /**
50 * Constructor to create port pair id from string.
51 *
52 * @param id port pair id in string
53 * @return object of port pair id
54 */
Mahesh Poojary Se74f9012015-10-29 12:22:47 +053055 public static PortPairId portPairId(final String id) {
Phaneendra Manda635f6212015-10-26 18:27:41 +053056 return new PortPairId(UUID.fromString(id));
57 }
58
59 /**
60 * Returns teh value of port pair id.
61 *
62 * @return port pair id
63 */
64 public UUID value() {
65 return portPairId;
66 }
67
68 @Override
69 public boolean equals(Object obj) {
70 if (this == obj) {
71 return true;
72 }
Mahesh Poojary Se74f9012015-10-29 12:22:47 +053073 if (obj instanceof PortPairId) {
74 final PortPairId other = (PortPairId) obj;
75 return Objects.equals(this.portPairId, other.portPairId);
Phaneendra Manda635f6212015-10-26 18:27:41 +053076 }
77 return false;
78 }
79
80 @Override
81 public int hashCode() {
82 return Objects.hashCode(this.portPairId);
83 }
84
85 @Override
86 public String toString() {
Mahesh Poojary Se74f9012015-10-29 12:22:47 +053087 return toStringHelper(this).add("portPairId", portPairId.toString()).toString();
Phaneendra Manda635f6212015-10-26 18:27:41 +053088 }
89}