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 | /** |
Sho SHIMIZU | 1674fb3 | 2014-08-20 14:44:31 -0700 | [diff] [blame] | 26 | * Constructor for serializer. |
| 27 | */ |
| 28 | protected PathFlowIntent() { |
| 29 | super(); |
| 30 | this.flow = null; |
| 31 | } |
| 32 | |
| 33 | /** |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 34 | * Returns {@link PacketPathFlow} object, which defines an explicit path. |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 35 | * |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 36 | * @return {@link PacketPathFlow path} |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 37 | */ |
Toshio Koide | 9aa4c0f | 2014-08-11 16:06:44 -0700 | [diff] [blame] | 38 | public PacketPathFlow getFlow() { |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 39 | return flow; |
Sho SHIMIZU | 6fa3af0 | 2014-08-14 14:18:39 -0700 | [diff] [blame] | 40 | } |
| 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 | } |