blob: d0d73d91ed4f3549c973c23acec3b8650f2de050 [file] [log] [blame]
weibitf32383b2014-10-22 10:17:31 -07001package org.onlab.onos.net.intent;
2
3import java.util.Collection;
4import java.util.Objects;
5
6import org.onlab.onos.net.ConnectPoint;
7import org.onlab.onos.net.Link;
8import org.onlab.onos.net.Path;
9import org.onlab.onos.net.flow.TrafficSelector;
10import org.onlab.onos.net.flow.TrafficTreatment;
11
12import com.google.common.base.MoreObjects;
13
14public class OpticalPathIntent extends OpticalConnectivityIntent implements InstallableIntent {
15
16 private final Path path;
17 private final TrafficSelector opticalMatch;
18 private final TrafficTreatment opticalAction;
19
20 public OpticalPathIntent(IntentId id, TrafficSelector match, TrafficTreatment action,
21 ConnectPoint ingressPort, ConnectPoint egressPort,
22 Path path) {
23 this.opticalMatch = match;
24 this.opticalAction = action;
25 this.path = path;
26 }
27
28 public OpticalPathIntent() {
29 this.opticalMatch = null;
30 this.opticalAction = null;
31 this.path = null;
32 }
33
34 public Path path() {
35 return path;
36 }
37
38 public TrafficSelector selector() {
39 return opticalMatch;
40 }
41
42 public TrafficTreatment treatment() {
43 return opticalAction;
44 }
45
46 @Override
47 public boolean equals(Object o) {
48 if (this == o) {
49 return true;
50 }
51 if (o == null || getClass() != o.getClass()) {
52 return false;
53 }
54 if (!super.equals(o)) {
55 return false;
56 }
57
58 OpticalPathIntent that = (OpticalPathIntent) o;
59
60 if (!path.equals(that.path)) {
61 return false;
62 }
63
64 return true;
65 }
66
67 @Override
68 public int hashCode() {
69 return Objects.hash(super.hashCode(), path);
70 }
71
72 @Override
73 public String toString() {
74 return MoreObjects.toStringHelper(getClass())
75 .add("id", id())
76 .add("match", opticalMatch)
77 .add("action", opticalAction)
78 .add("ingressPort", this.getSrcConnectPoint())
79 .add("egressPort", this.getDst())
80 .add("path", path)
81 .toString();
82 }
83
84 @Override
85 public Collection<Link> requiredLinks() {
86 return path.links();
87 }
88}