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 | /** |
Sho SHIMIZU | 1674fb3 | 2014-08-20 14:44:31 -0700 | [diff] [blame] | 32 | * Constructor for serializer. |
| 33 | */ |
| 34 | protected SingleDstTreeFlowIntent() { |
| 35 | super(); |
| 36 | this.tree = null; |
| 37 | } |
| 38 | |
| 39 | /** |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 40 | * Returns the tree. |
| 41 | * |
| 42 | * @return tree |
| 43 | */ |
| 44 | public SingleDstTreeFlow getTree() { |
| 45 | return tree; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public boolean equals(Object o) { |
| 50 | if (this == o) { |
| 51 | return true; |
| 52 | } |
| 53 | if (o == null || getClass() != o.getClass()) { |
| 54 | return false; |
| 55 | } |
| 56 | if (!super.equals(o)) { |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | SingleDstTreeFlowIntent that = (SingleDstTreeFlowIntent) o; |
| 61 | return Objects.equal(this.tree, that.tree); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public int hashCode() { |
| 66 | return Objects.hashCode(super.hashCode(), tree); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public String toString() { |
| 71 | return Objects.toStringHelper(getClass()) |
| 72 | .add("id", getId()) |
| 73 | .add("tree", tree) |
| 74 | .toString(); |
| 75 | } |
| 76 | } |