blob: 89d7760be75e291faf7704dc93087a9deb4a0e4f [file] [log] [blame]
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -07001package net.onrc.onos.core.newintent;
2
Toshio Koide9aa4c0f2014-08-11 16:06:44 -07003import static com.google.common.base.Preconditions.checkNotNull;
4import net.onrc.onos.api.flowmanager.PacketPathFlow;
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -07005import net.onrc.onos.api.newintent.AbstractIntent;
6import net.onrc.onos.api.newintent.InstallableIntent;
7import net.onrc.onos.api.newintent.IntentId;
8
Toshio Koide9aa4c0f2014-08-11 16:06:44 -07009import com.google.common.base.Objects;
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070010
11/**
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070012 * Intent containing {@link PacketPathFlow} object, which defines an explicit path.
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070013 *
14 * It is intended to establish a path by using Flow Manager's API.
15 */
16public class PathFlowIntent extends AbstractIntent implements InstallableIntent {
17
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070018 private final PacketPathFlow flow;
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070019
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070020 public PathFlowIntent(IntentId id, PacketPathFlow flow) {
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070021 super(id);
22 this.flow = checkNotNull(flow);
23 }
24
25 /**
Sho SHIMIZU1674fb32014-08-20 14:44:31 -070026 * Constructor for serializer.
27 */
28 protected PathFlowIntent() {
29 super();
30 this.flow = null;
31 }
32
33 /**
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070034 * Returns {@link PacketPathFlow} object, which defines an explicit path.
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070035 *
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070036 * @return {@link PacketPathFlow path}
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070037 */
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070038 public PacketPathFlow getFlow() {
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070039 return flow;
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070040 }
41
42 @Override
43 public boolean equals(Object o) {
44 if (this == o) {
45 return true;
46 }
47 if (o == null || getClass() != o.getClass()) {
48 return false;
49 }
50 if (!super.equals(o)) {
51 return false;
52 }
53
54 PathFlowIntent that = (PathFlowIntent) o;
55 return Objects.equal(this.flow, that.flow);
56 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hashCode(super.hashCode(), flow);
61 }
62
63 @Override
64 public String toString() {
65 return Objects.toStringHelper(getClass())
66 .add("id", getId())
67 .add("flow", flow)
68 .toString();
69 }
70}