blob: 37a171654bbc164aa6ca926bbd7253c69b33dda1 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
Brian O'Connorb876bf12014-10-02 14:59:37 -070017
18import java.util.Objects;
19
20import com.google.common.base.MoreObjects;
21
22/**
23 * A super class for batch operation entry classes.
24 * <p>
25 * This is the interface to classes which are maintained by BatchOperation as
26 * its entries.
27 */
28public class BatchOperationEntry<T extends Enum<?>, U extends BatchOperationTarget> {
29 private final T operator;
30 private final U target;
31
alshabib902d41b2014-10-07 16:52:05 -070032
Brian O'Connorb876bf12014-10-02 14:59:37 -070033
34 /**
35 * Constructs new instance for the entry of the BatchOperation.
36 *
37 * @param operator the operator of this operation
38 * @param target the target object of this operation
39 */
40 public BatchOperationEntry(T operator, U target) {
41 this.operator = operator;
42 this.target = target;
43 }
44
45 /**
46 * Gets the target object of this operation.
47 *
48 * @return the target object of this operation
49 */
50 public U getTarget() {
51 return target;
52 }
53
54 /**
55 * Gets the operator of this operation.
56 *
57 * @return the operator of this operation
58 */
59 public T getOperator() {
60 return operator;
61 }
62
63 @Override
64 public boolean equals(Object o) {
65 if (this == o) {
66 return true;
67 }
68 if (o == null || getClass() != o.getClass()) {
69 return false;
70 }
71
72 BatchOperationEntry<?, ?> other = (BatchOperationEntry<?, ?>) o;
73 return (this.operator == other.operator) &&
74 Objects.equals(this.target, other.target);
75 }
76
77 @Override
78 public int hashCode() {
79 return Objects.hash(operator, target);
80 }
81
82 @Override
83 public String toString() {
84 return MoreObjects.toStringHelper(this)
85 .add("operator", operator)
86 .add("target", target)
87 .toString();
88 }
89}