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