Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
| 4 | import net.onrc.onos.api.flowmanager.PacketPathFlow; |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 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 | |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 9 | import com.google.common.base.Objects; |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 12 | * Intent containing {@link PacketPathFlow} object, which defines an explicit path. |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 13 | * |
| 14 | * It is intended to establish a path by using Flow Manager's API. |
| 15 | */ |
| 16 | public class PathFlowIntent extends AbstractIntent implements InstallableIntent { |
| 17 | |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 18 | private final PacketPathFlow flow; |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 19 | |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 20 | public PathFlowIntent(IntentId id, PacketPathFlow flow) { |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 21 | super(id); |
| 22 | this.flow = checkNotNull(flow); |
| 23 | } |
| 24 | |
| 25 | /** |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 26 | * Returns {@link PacketPathFlow} object, which defines an explicit path. |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 27 | * |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 28 | * @return {@link PacketPathFlow path} |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 29 | */ |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 30 | public PacketPathFlow getFlow() { |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 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 | } |