blob: 39a18980278153db5f7f1cade2c598d7bd2bf789 [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 /**
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070026 * Returns {@link PacketPathFlow} object, which defines an explicit path.
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070027 *
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070028 * @return {@link PacketPathFlow path}
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070029 */
Toshio Koide9aa4c0f2014-08-11 16:06:44 -070030 public PacketPathFlow getFlow() {
Sho SHIMIZU6fa3af02014-08-14 14:18:39 -070031 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}