blob: 781e3d16ddbcfcb0a4bd98ba250ae402872f3547 [file] [log] [blame]
Brian O'Connorb876bf12014-10-02 14:59:37 -07001package org.onlab.onos.net.intent;
2
3import java.util.Objects;
4
5import com.google.common.base.MoreObjects;
6
7/**
8 * A super class for batch operation entry classes.
9 * <p>
10 * This is the interface to classes which are maintained by BatchOperation as
11 * its entries.
12 */
13public class BatchOperationEntry<T extends Enum<?>, U extends BatchOperationTarget> {
14 private final T operator;
15 private final U target;
16
17 /**
18 * Default constructor for serializer.
19 */
20 @Deprecated
21 protected BatchOperationEntry() {
22 this.operator = null;
23 this.target = null;
24 }
25
26 /**
27 * Constructs new instance for the entry of the BatchOperation.
28 *
29 * @param operator the operator of this operation
30 * @param target the target object of this operation
31 */
32 public BatchOperationEntry(T operator, U target) {
33 this.operator = operator;
34 this.target = target;
35 }
36
37 /**
38 * Gets the target object of this operation.
39 *
40 * @return the target object of this operation
41 */
42 public U getTarget() {
43 return target;
44 }
45
46 /**
47 * Gets the operator of this operation.
48 *
49 * @return the operator of this operation
50 */
51 public T getOperator() {
52 return operator;
53 }
54
55 @Override
56 public boolean equals(Object o) {
57 if (this == o) {
58 return true;
59 }
60 if (o == null || getClass() != o.getClass()) {
61 return false;
62 }
63
64 BatchOperationEntry<?, ?> other = (BatchOperationEntry<?, ?>) o;
65 return (this.operator == other.operator) &&
66 Objects.equals(this.target, other.target);
67 }
68
69 @Override
70 public int hashCode() {
71 return Objects.hash(operator, target);
72 }
73
74 @Override
75 public String toString() {
76 return MoreObjects.toStringHelper(this)
77 .add("operator", operator)
78 .add("target", target)
79 .toString();
80 }
81}