blob: 890c59bd8d8897412746804c652e85ec5cb4aec0 [file] [log] [blame]
Hyunsun Moona08c5d02015-07-14 17:53:00 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Hyunsun Moona08c5d02015-07-14 17:53:00 -07003 *
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.net.flow.criteria;
17
18import java.util.Objects;
Hyunsun Moona08c5d02015-07-14 17:53:00 -070019/**
20 * Implementation of Tunnel ID criterion.
21 */
22public class TunnelIdCriterion implements Criterion {
23 private final long tunnelId;
24
25 /**
26 * Constructor.
27 *
28 * @param tunnelId a Tunnel ID to match(64 bits)
29 */
30 TunnelIdCriterion(long tunnelId) {
31 this.tunnelId = tunnelId;
32 }
33
34 @Override
35 public Type type() {
36 return Type.TUNNEL_ID;
37 }
38
39 /**
40 * Gets the Tunnel ID to match.
41 *
42 * @return the Tunnel ID to match (64 bits)
43 */
44 public long tunnelId() {
45 return tunnelId;
46 }
47
48 @Override
49 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080050 return type().toString() + SEPARATOR + Long.toHexString(tunnelId);
Hyunsun Moona08c5d02015-07-14 17:53:00 -070051 }
52
53 @Override
54 public int hashCode() {
55 return Objects.hash(type().ordinal(), tunnelId);
56 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof TunnelIdCriterion) {
64 TunnelIdCriterion that = (TunnelIdCriterion) obj;
65 return Objects.equals(tunnelId, that.tunnelId) &&
66 Objects.equals(this.type(), that.type());
67 }
68 return false;
69 }
70}