alshabib | 7b2748f | 2014-09-16 20:21:11 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.flow; |
| 2 | |
| 3 | import org.onlab.onos.net.DeviceId; |
| 4 | |
| 5 | public class DefaultFlowRule implements FlowRule { |
| 6 | |
| 7 | private final TrafficSelector selector; |
| 8 | private final TrafficTreatment treatment; |
| 9 | private final DeviceId deviceId; |
| 10 | |
| 11 | public DefaultFlowRule(DeviceId deviceId, |
| 12 | TrafficSelector selector, TrafficTreatment treatment) { |
| 13 | this.treatment = treatment; |
| 14 | this.selector = selector; |
| 15 | this.deviceId = deviceId; |
| 16 | } |
| 17 | |
| 18 | @Override |
| 19 | public int priority() { |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame^] | 20 | // is this supposed to be 0? |
alshabib | 7b2748f | 2014-09-16 20:21:11 -0700 | [diff] [blame] | 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | @Override |
| 25 | public DeviceId deviceId() { |
| 26 | return deviceId; |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public TrafficSelector selector() { |
| 31 | return selector; |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public TrafficTreatment treatment() { |
| 36 | return treatment; |
| 37 | } |
| 38 | |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 39 | @Override |
| 40 | public int hashCode() { |
| 41 | final int prime = 31; |
| 42 | int result = prime * this.deviceId().hashCode(); |
| 43 | result = prime * result + selector.hashCode(); |
| 44 | result = prime * result + treatment.hashCode(); |
| 45 | return result; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | /* |
| 50 | * The priority and statistics can change on a given treatment and selector |
| 51 | * |
| 52 | * (non-Javadoc) |
| 53 | * @see java.lang.Object#equals(java.lang.Object) |
| 54 | */ |
| 55 | public boolean equals(Object obj) { |
| 56 | if (obj instanceof FlowRule) { |
| 57 | DefaultFlowRule that = (DefaultFlowRule) obj; |
| 58 | if (!this.deviceId().equals(that.deviceId())) { |
| 59 | return false; |
| 60 | } |
| 61 | if (!this.treatment().equals(that.treatment())) { |
| 62 | return false; |
| 63 | } |
| 64 | if (!this.selector().equals(that.selector())) { |
| 65 | return false; |
| 66 | } |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame^] | 67 | return true; |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 68 | } |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame^] | 69 | return false; |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | |
alshabib | 7b2748f | 2014-09-16 20:21:11 -0700 | [diff] [blame] | 73 | } |