blob: 2ea7053c1429db03d73ee3059ba6d45d7f55a1e9 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.onlab.onos.net.flow;
Brian O'Connorb876bf12014-10-02 14:59:37 -070020
21import java.util.Objects;
22
23import com.google.common.base.MoreObjects;
24
25/**
26 * A super class for batch operation entry classes.
27 * <p>
28 * This is the interface to classes which are maintained by BatchOperation as
29 * its entries.
30 */
31public class BatchOperationEntry<T extends Enum<?>, U extends BatchOperationTarget> {
32 private final T operator;
33 private final U target;
34
alshabib902d41b2014-10-07 16:52:05 -070035
Brian O'Connorb876bf12014-10-02 14:59:37 -070036
37 /**
38 * Constructs new instance for the entry of the BatchOperation.
39 *
40 * @param operator the operator of this operation
41 * @param target the target object of this operation
42 */
43 public BatchOperationEntry(T operator, U target) {
44 this.operator = operator;
45 this.target = target;
46 }
47
48 /**
49 * Gets the target object of this operation.
50 *
51 * @return the target object of this operation
52 */
53 public U getTarget() {
54 return target;
55 }
56
57 /**
58 * Gets the operator of this operation.
59 *
60 * @return the operator of this operation
61 */
62 public T getOperator() {
63 return operator;
64 }
65
66 @Override
67 public boolean equals(Object o) {
68 if (this == o) {
69 return true;
70 }
71 if (o == null || getClass() != o.getClass()) {
72 return false;
73 }
74
75 BatchOperationEntry<?, ?> other = (BatchOperationEntry<?, ?>) o;
76 return (this.operator == other.operator) &&
77 Objects.equals(this.target, other.target);
78 }
79
80 @Override
81 public int hashCode() {
82 return Objects.hash(operator, target);
83 }
84
85 @Override
86 public String toString() {
87 return MoreObjects.toStringHelper(this)
88 .add("operator", operator)
89 .add("target", target)
90 .toString();
91 }
92}