blob: d20e79e885d187a0c3332c1622baea993f0a786e [file] [log] [blame]
alshabib7b2748f2014-09-16 20:21:11 -07001package org.onlab.onos.net.flow;
2
3import org.onlab.onos.net.DeviceId;
4
5public 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 Koshibeb55524f2014-09-18 09:59:24 -070020 // is this supposed to be 0?
alshabib7b2748f2014-09-16 20:21:11 -070021 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 Koshibe08eabaa2014-09-17 14:59:25 -070039 @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 Koshibeb55524f2014-09-18 09:59:24 -070067 return true;
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -070068 }
Ayaka Koshibeb55524f2014-09-18 09:59:24 -070069 return false;
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -070070 }
71
72
alshabib7b2748f2014-09-16 20:21:11 -070073}