blob: 5d7491f742053a6d196b54b480683ccfbe76563b [file] [log] [blame]
BitOhenry11620c92015-11-27 08:42:36 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
BitOhenry11620c92015-11-27 08:42:36 +08003 *
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
BitOhenry11620c92015-11-27 08:42:36 +080018import java.util.Objects;
19
20/**
21 * Implementation of arp operation type criterion.
22 */
23public final class ArpOpCriterion implements Criterion {
24 private final int arpOp;
25 private final Type type;
26
27 /**
28 * Constructor.
29 *
30 * @param arpOp the arp operation type to match.
31 * @param type the match type. Should be the following:
32 * Type.ARP_OP
33 */
34 ArpOpCriterion(int arpOp, Type type) {
35 this.arpOp = arpOp;
36 this.type = type;
37 }
38
39 @Override
40 public Type type() {
41 return this.type;
42 }
43
44 /**
45 * Gets the arp operation type to match.
46 *
47 * @return the arp operation type to match
48 */
49 public int arpOp() {
50 return this.arpOp;
51 }
52
53 @Override
54 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080055 return type().toString() + SEPARATOR + arpOp;
BitOhenry11620c92015-11-27 08:42:36 +080056 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hash(type().ordinal(), arpOp);
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68 if (obj instanceof ArpOpCriterion) {
69 ArpOpCriterion that = (ArpOpCriterion) obj;
70 return Objects.equals(arpOp, that.arpOp) &&
71 Objects.equals(type, that.type);
72 }
73 return false;
74 }
Jonathan Hartc7840bd2016-01-21 23:26:29 -080075}