blob: 9a240911df211c66c47c15f21b9246fba54c3557 [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() {
20 return 0;
21 }
22
23 @Override
24 public DeviceId deviceId() {
25 return deviceId;
26 }
27
28 @Override
29 public TrafficSelector selector() {
30 return selector;
31 }
32
33 @Override
34 public TrafficTreatment treatment() {
35 return treatment;
36 }
37
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -070038 @Override
39 public int hashCode() {
40 final int prime = 31;
41 int result = prime * this.deviceId().hashCode();
42 result = prime * result + selector.hashCode();
43 result = prime * result + treatment.hashCode();
44 return result;
45 }
46
47 @Override
48 /*
49 * The priority and statistics can change on a given treatment and selector
50 *
51 * (non-Javadoc)
52 * @see java.lang.Object#equals(java.lang.Object)
53 */
54 public boolean equals(Object obj) {
55 if (obj instanceof FlowRule) {
56 DefaultFlowRule that = (DefaultFlowRule) obj;
57 if (!this.deviceId().equals(that.deviceId())) {
58 return false;
59 }
60 if (!this.treatment().equals(that.treatment())) {
61 return false;
62 }
63 if (!this.selector().equals(that.selector())) {
64 return false;
65 }
66 }
67 return true;
68 }
69
70
alshabib7b2748f2014-09-16 20:21:11 -070071}