blob: a52a2bb3ceaad20dbf60de385599e73e4354ac44 [file] [log] [blame]
Phaneendra Manda1b50fac2015-10-26 18:43:42 +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 Huaweif5f1edd2015-11-05 11:28:01 +053022import java.util.Objects;
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053023
24/**
25 * Representation of a Port Pair Group ID.
26 */
27public final class PortPairGroupId {
28
29 private final UUID portPairGroupId;
30
31 /**
32 * Private constructor for port pair group id.
33 *
34 * @param id UUID id of port pair group
35 */
36 private PortPairGroupId(UUID id) {
37 checkNotNull(id, "Port pair group id can not be null");
38 this.portPairGroupId = id;
39 }
40
41 /**
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053042 * Returns newly created port pair group id object.
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053043 *
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053044 * @param id port pair group id in UUID
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053045 * @return object of port pair group id
46 */
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053047 public static PortPairGroupId of(UUID id) {
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053048 return new PortPairGroupId(id);
49 }
50
51 /**
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053052 * Returns newly created port pair group id object.
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053053 *
54 * @param id port pair group id in string
55 * @return object of port pair group id
56 */
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053057 public static PortPairGroupId of(String id) {
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053058 return new PortPairGroupId(UUID.fromString(id));
59 }
60
61 /**
62 * Returns the value of port pair group id.
63 *
64 * @return port pair group id
65 */
66 public UUID value() {
67 return portPairGroupId;
68 }
69
70 @Override
71 public boolean equals(Object obj) {
72 if (this == obj) {
73 return true;
74 }
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053075 if (obj instanceof PortPairGroupId) {
76 final PortPairGroupId other = (PortPairGroupId) obj;
77 return Objects.equals(this.portPairGroupId, other.portPairGroupId);
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053078 }
79 return false;
80 }
81
82 @Override
83 public int hashCode() {
84 return Objects.hashCode(this.portPairGroupId);
85 }
86
87 @Override
88 public String toString() {
Mahesh Poojary Huaweif5f1edd2015-11-05 11:28:01 +053089 return toStringHelper(this).add("portPairGroupId", portPairGroupId)
Phaneendra Manda1b50fac2015-10-26 18:43:42 +053090 .toString();
91 }
92}