blob: 988a8b341c889f4c5043a4b7dc8cbb118cccd2e1 [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.PathFlow;
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 PathFlow} object, which defines an explicit path.
13 *
14 * It is intended to establish a path by using Flow Manager's API.
15 */
16public class PathFlowIntent extends AbstractIntent implements InstallableIntent {
17
18 private final PathFlow flow;
19
20 public PathFlowIntent(IntentId id, PathFlow flow) {
21 super(id);
22 this.flow = checkNotNull(flow);
23 }
24
25 /**
26 * Returns {@link PathFlow} object, which defines an explicit path.
27 *
28 * @return {@link PathFlow path}
29 */
30 public PathFlow getFlow() {
31 return flow;
32
33 }
34
35 @Override
36 public boolean equals(Object o) {
37 if (this == o) {
38 return true;
39 }
40 if (o == null || getClass() != o.getClass()) {
41 return false;
42 }
43 if (!super.equals(o)) {
44 return false;
45 }
46
47 PathFlowIntent that = (PathFlowIntent) o;
48 return Objects.equal(this.flow, that.flow);
49 }
50
51 @Override
52 public int hashCode() {
53 return Objects.hashCode(super.hashCode(), flow);
54 }
55
56 @Override
57 public String toString() {
58 return Objects.toStringHelper(getClass())
59 .add("id", getId())
60 .add("flow", flow)
61 .toString();
62 }
63}