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