blob: 4c3486f51fdd54bf9f5ec91e83845fc55faaf5d8 [file] [log] [blame]
Brian O'Connorb876bf12014-10-02 14:59:37 -07001package org.onlab.onos.net.intent;
2
tom95329eb2014-10-06 08:40:06 -07003import com.google.common.base.MoreObjects;
Brian O'Connorb876bf12014-10-02 14:59:37 -07004import org.onlab.onos.net.ConnectPoint;
tom95329eb2014-10-06 08:40:06 -07005import org.onlab.onos.net.Link;
Brian O'Connorb876bf12014-10-02 14:59:37 -07006import org.onlab.onos.net.Path;
7import org.onlab.onos.net.flow.TrafficSelector;
8import org.onlab.onos.net.flow.TrafficTreatment;
9
tom95329eb2014-10-06 08:40:06 -070010import java.util.Collection;
11import java.util.Objects;
Brian O'Connorb876bf12014-10-02 14:59:37 -070012
13/**
14 * Abstraction of explicitly path specified connectivity intent.
15 */
Brian O'Connor66630c82014-10-02 21:08:19 -070016public class PathIntent extends PointToPointIntent implements InstallableIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070017
18 private final Path path;
19
20 /**
21 * Creates a new point-to-point intent with the supplied ingress/egress
22 * ports and using the specified explicit path.
23 *
24 * @param id intent identifier
25 * @param match traffic match
26 * @param action action
27 * @param ingressPort ingress port
28 * @param egressPort egress port
29 * @param path traversed links
30 * @throws NullPointerException {@code path} is null
31 */
32 public PathIntent(IntentId id, TrafficSelector match, TrafficTreatment action,
33 ConnectPoint ingressPort, ConnectPoint egressPort,
34 Path path) {
35 super(id, match, action, ingressPort, egressPort);
36 this.path = path;
37 }
38
39 protected PathIntent() {
40 super();
41 this.path = null;
42 }
43
44 /**
45 * Returns the links which the traffic goes along.
46 *
47 * @return traversed links
48 */
49 public Path getPath() {
50 return path;
51 }
52
53 @Override
54 public boolean equals(Object o) {
55 if (this == o) {
56 return true;
57 }
58 if (o == null || getClass() != o.getClass()) {
59 return false;
60 }
61 if (!super.equals(o)) {
62 return false;
63 }
64
65 PathIntent that = (PathIntent) o;
66
67 if (!path.equals(that.path)) {
68 return false;
69 }
70
71 return true;
72 }
73
74 @Override
75 public int hashCode() {
76 return Objects.hash(super.hashCode(), path);
77 }
78
79 @Override
80 public String toString() {
81 return MoreObjects.toStringHelper(getClass())
82 .add("id", getId())
83 .add("match", getTrafficSelector())
84 .add("action", getTrafficTreatment())
85 .add("ingressPort", getIngressPort())
86 .add("egressPort", getEgressPort())
87 .add("path", path)
88 .toString();
89 }
tom95329eb2014-10-06 08:40:06 -070090
91 @Override
92 public Collection<Link> requiredLinks() {
93 return path.links();
94 }
95
Brian O'Connorb876bf12014-10-02 14:59:37 -070096}