blob: 4e57d335a766ea103cabc83efcc280478a1df817 [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
alshabib902d41b2014-10-07 16:52:05 -070018
Brian O'Connorb876bf12014-10-02 14:59:37 -070019
20 /**
21 * Constructs new instance for the entry of the BatchOperation.
22 *
23 * @param operator the operator of this operation
24 * @param target the target object of this operation
25 */
26 public BatchOperationEntry(T operator, U target) {
27 this.operator = operator;
28 this.target = target;
29 }
30
31 /**
32 * Gets the target object of this operation.
33 *
34 * @return the target object of this operation
35 */
36 public U getTarget() {
37 return target;
38 }
39
40 /**
41 * Gets the operator of this operation.
42 *
43 * @return the operator of this operation
44 */
45 public T getOperator() {
46 return operator;
47 }
48
49 @Override
50 public boolean equals(Object o) {
51 if (this == o) {
52 return true;
53 }
54 if (o == null || getClass() != o.getClass()) {
55 return false;
56 }
57
58 BatchOperationEntry<?, ?> other = (BatchOperationEntry<?, ?>) o;
59 return (this.operator == other.operator) &&
60 Objects.equals(this.target, other.target);
61 }
62
63 @Override
64 public int hashCode() {
65 return Objects.hash(operator, target);
66 }
67
68 @Override
69 public String toString() {
70 return MoreObjects.toStringHelper(this)
71 .add("operator", operator)
72 .add("target", target)
73 .toString();
74 }
75}