Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
| 3 | import java.util.Objects; |
| 4 | |
| 5 | import 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 | */ |
| 13 | public 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 | } |