Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [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 static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | import static com.google.common.base.Preconditions.checkNotNull; |
| 20 | |
| 21 | import java.util.UUID; |
Mahesh Poojary Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 22 | import java.util.Objects; |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Representation of a Port Pair Group ID. |
| 26 | */ |
| 27 | public 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 Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 42 | * Returns newly created port pair group id object. |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 43 | * |
Mahesh Poojary Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 44 | * @param id port pair group id in UUID |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 45 | * @return object of port pair group id |
| 46 | */ |
Mahesh Poojary Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 47 | public static PortPairGroupId of(UUID id) { |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 48 | return new PortPairGroupId(id); |
| 49 | } |
| 50 | |
| 51 | /** |
Mahesh Poojary Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 52 | * Returns newly created port pair group id object. |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 53 | * |
| 54 | * @param id port pair group id in string |
| 55 | * @return object of port pair group id |
| 56 | */ |
Mahesh Poojary Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 57 | public static PortPairGroupId of(String id) { |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 58 | 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 Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 75 | if (obj instanceof PortPairGroupId) { |
| 76 | final PortPairGroupId other = (PortPairGroupId) obj; |
| 77 | return Objects.equals(this.portPairGroupId, other.portPairGroupId); |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 78 | } |
| 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 Huawei | f5f1edd | 2015-11-05 11:28:01 +0530 | [diff] [blame] | 89 | return toStringHelper(this).add("portPairGroupId", portPairGroupId) |
Phaneendra Manda | 1b50fac | 2015-10-26 18:43:42 +0530 | [diff] [blame] | 90 | .toString(); |
| 91 | } |
| 92 | } |