Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
Brian O'Connor | f3d0616 | 2014-10-02 15:54:12 -0700 | [diff] [blame] | 2 | //TODO is this the right package? |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 3 | |
| 4 | import java.util.Objects; |
| 5 | |
| 6 | import 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 | */ |
| 14 | public class BatchOperationEntry<T extends Enum<?>, U extends BatchOperationTarget> { |
| 15 | private final T operator; |
| 16 | private final U target; |
| 17 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 18 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 19 | |
| 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 | } |