blob: 3c7a365e19e0fc8b7037ce09b49c3d49f235e6a2 [file] [log] [blame]
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -07001package net.onrc.onos.core.newintent;
2
3import com.google.common.base.Objects;
4import net.onrc.onos.api.flowmanager.SingleDstTreeFlow;
5import net.onrc.onos.api.newintent.AbstractIntent;
6import net.onrc.onos.api.newintent.InstallableIntent;
7import net.onrc.onos.api.newintent.IntentId;
8
9import 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 */
16public 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 SHIMIZU1674fb32014-08-20 14:44:31 -070032 * Constructor for serializer.
33 */
34 protected SingleDstTreeFlowIntent() {
35 super();
36 this.tree = null;
37 }
38
39 /**
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070040 * 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}