blob: df180ebe3806f630c0d11e1fc00e3a2690b5a986 [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
Mahesh Poojary Huawei321cc502015-11-03 13:23:32 +053018import static com.google.common.base.Preconditions.checkNotNull;
19
Bharat saraswalb0748142015-10-26 12:22:16 +053020import com.google.common.base.MoreObjects;
21
Mahesh Poojary S2b03bf62015-10-29 11:40:46 +053022import java.util.UUID;
23import java.util.Objects;
24
Bharat saraswalb0748142015-10-26 12:22:16 +053025/**
26 * Flow classification identifier.
27 */
28public final class FlowClassifierId {
29
30 private final UUID flowClassifierId;
31
32 /**
33 * Constructor to create flow classifier id.
34 *
35 * @param flowClassifierId flow classifier id.
36 */
37 private FlowClassifierId(final UUID flowClassifierId) {
Mahesh Poojary Huawei321cc502015-11-03 13:23:32 +053038 checkNotNull(flowClassifierId, "Flow classifier id can not be null");
Bharat saraswalb0748142015-10-26 12:22:16 +053039 this.flowClassifierId = flowClassifierId;
40 }
41
42 /**
43 * Returns new flow classifier id.
44 *
45 * @param flowClassifierId flow classifier id
46 * @return new flow classifier id
47 */
Mahesh Poojary Huawei321cc502015-11-03 13:23:32 +053048 public static FlowClassifierId of(final UUID flowClassifierId) {
Bharat saraswalb0748142015-10-26 12:22:16 +053049 return new FlowClassifierId(flowClassifierId);
50 }
51
Bharat saraswalbf78f4f2015-10-28 19:24:56 +053052 /**
53 * Returns new flow classifier id.
54 *
55 * @param flowClassifierId flow classifier id
56 * @return new flow classifier id
57 */
Mahesh Poojary Huawei321cc502015-11-03 13:23:32 +053058 public static FlowClassifierId of(final String flowClassifierId) {
Bharat saraswalbf78f4f2015-10-28 19:24:56 +053059 return new FlowClassifierId(UUID.fromString(flowClassifierId));
60 }
61
Mahesh Poojary S2b03bf62015-10-29 11:40:46 +053062 /**
63 * Returns the value of flow classifier id.
64 *
65 * @return flow classifier id.
66 */
67 public UUID value() {
68 return flowClassifierId;
69 }
70
Bharat saraswalb0748142015-10-26 12:22:16 +053071 @Override
72 public int hashCode() {
73 return Objects.hashCode(this.flowClassifierId);
74 }
75
76 @Override
77 public boolean equals(Object obj) {
78 if (this == obj) {
79 return true;
80 }
81 if (obj instanceof FlowClassifierId) {
82 final FlowClassifierId other = (FlowClassifierId) obj;
83 return Objects.equals(this.flowClassifierId, other.flowClassifierId);
84 }
85 return false;
86 }
87
88 @Override
89 public String toString() {
90 return MoreObjects.toStringHelper(getClass())
91 .add("FlowClassifierId", flowClassifierId)
92 .toString();
93 }
94}