Bharat saraswal | b074814 | 2015-10-26 12:22:16 +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 | |
Bharat saraswal | b074814 | 2015-10-26 12:22:16 +0530 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
| 19 | |
Mahesh Poojary S | 2b03bf6 | 2015-10-29 11:40:46 +0530 | [diff] [blame] | 20 | import java.util.UUID; |
| 21 | import java.util.Objects; |
| 22 | |
Bharat saraswal | b074814 | 2015-10-26 12:22:16 +0530 | [diff] [blame] | 23 | /** |
| 24 | * Flow classification identifier. |
| 25 | */ |
| 26 | public final class FlowClassifierId { |
| 27 | |
| 28 | private final UUID flowClassifierId; |
| 29 | |
| 30 | /** |
| 31 | * Constructor to create flow classifier id. |
| 32 | * |
| 33 | * @param flowClassifierId flow classifier id. |
| 34 | */ |
| 35 | private FlowClassifierId(final UUID flowClassifierId) { |
| 36 | this.flowClassifierId = flowClassifierId; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Returns new flow classifier id. |
| 41 | * |
| 42 | * @param flowClassifierId flow classifier id |
| 43 | * @return new flow classifier id |
| 44 | */ |
| 45 | public static FlowClassifierId flowClassifierId(final UUID flowClassifierId) { |
| 46 | return new FlowClassifierId(flowClassifierId); |
| 47 | } |
| 48 | |
Bharat saraswal | bf78f4f | 2015-10-28 19:24:56 +0530 | [diff] [blame] | 49 | /** |
| 50 | * Returns new flow classifier id. |
| 51 | * |
| 52 | * @param flowClassifierId flow classifier id |
| 53 | * @return new flow classifier id |
| 54 | */ |
| 55 | public static FlowClassifierId flowClassifierId(final String flowClassifierId) { |
| 56 | return new FlowClassifierId(UUID.fromString(flowClassifierId)); |
| 57 | } |
| 58 | |
Mahesh Poojary S | 2b03bf6 | 2015-10-29 11:40:46 +0530 | [diff] [blame] | 59 | /** |
| 60 | * Returns the value of flow classifier id. |
| 61 | * |
| 62 | * @return flow classifier id. |
| 63 | */ |
| 64 | public UUID value() { |
| 65 | return flowClassifierId; |
| 66 | } |
| 67 | |
Bharat saraswal | b074814 | 2015-10-26 12:22:16 +0530 | [diff] [blame] | 68 | @Override |
| 69 | public int hashCode() { |
| 70 | return Objects.hashCode(this.flowClassifierId); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public boolean equals(Object obj) { |
| 75 | if (this == obj) { |
| 76 | return true; |
| 77 | } |
| 78 | if (obj instanceof FlowClassifierId) { |
| 79 | final FlowClassifierId other = (FlowClassifierId) obj; |
| 80 | return Objects.equals(this.flowClassifierId, other.flowClassifierId); |
| 81 | } |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public String toString() { |
| 87 | return MoreObjects.toStringHelper(getClass()) |
| 88 | .add("FlowClassifierId", flowClassifierId) |
| 89 | .toString(); |
| 90 | } |
| 91 | } |