Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
| 3 | import com.google.common.base.Objects; |
| 4 | import net.onrc.onos.api.flowmanager.SingleDstTreeFlow; |
| 5 | import net.onrc.onos.api.newintent.AbstractIntent; |
| 6 | import net.onrc.onos.api.newintent.InstallableIntent; |
| 7 | import net.onrc.onos.api.newintent.IntentId; |
| 8 | |
| 9 | import static com.google.common.base.Preconditions.checkNotNull; |
| 10 | |
| 11 | /** |
| 12 | * Intent containing {@link SingleDstTreeFlow} object, which defines an explicit tree. |
| 13 | * |
| 14 | * It is intended to establish a path by using Flow Manager's API. |
| 15 | */ |
| 16 | public class SingleDstTreeFlowIntent extends AbstractIntent implements InstallableIntent { |
| 17 | |
| 18 | private final SingleDstTreeFlow tree; |
| 19 | |
| 20 | /** |
| 21 | * Constructs an intent containing the specified {@link SingleDstTreeFlow tree}. |
| 22 | * |
| 23 | * @param id intent identifier |
| 24 | * @param tree tree |
| 25 | */ |
| 26 | public SingleDstTreeFlowIntent(IntentId id, SingleDstTreeFlow tree) { |
| 27 | super(id); |
| 28 | this.tree = checkNotNull(tree); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Returns the tree. |
| 33 | * |
| 34 | * @return tree |
| 35 | */ |
| 36 | public SingleDstTreeFlow getTree() { |
| 37 | return tree; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public boolean equals(Object o) { |
| 42 | if (this == o) { |
| 43 | return true; |
| 44 | } |
| 45 | if (o == null || getClass() != o.getClass()) { |
| 46 | return false; |
| 47 | } |
| 48 | if (!super.equals(o)) { |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | SingleDstTreeFlowIntent that = (SingleDstTreeFlowIntent) o; |
| 53 | return Objects.equal(this.tree, that.tree); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public int hashCode() { |
| 58 | return Objects.hashCode(super.hashCode(), tree); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public String toString() { |
| 63 | return Objects.toStringHelper(getClass()) |
| 64 | .add("id", getId()) |
| 65 | .add("tree", tree) |
| 66 | .toString(); |
| 67 | } |
| 68 | } |