blob: b789abe3b0ab281566d21c79c4656d3a3b3e5535 [file] [log] [blame]
Bharat saraswalb0748142015-10-26 12:22:16 +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
Bharat saraswalb0748142015-10-26 12:22:16 +053018import com.google.common.base.MoreObjects;
19
Mahesh Poojary S2b03bf62015-10-29 11:40:46 +053020import java.util.UUID;
21import java.util.Objects;
22
Bharat saraswalb0748142015-10-26 12:22:16 +053023/**
24 * Flow classification identifier.
25 */
26public 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 saraswalbf78f4f2015-10-28 19:24:56 +053049 /**
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 S2b03bf62015-10-29 11:40:46 +053059 /**
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 saraswalb0748142015-10-26 12:22:16 +053068 @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}