blob: 51ce25e842ec1d5f38749a2562683a6321a14e9d [file] [log] [blame]
Sho SHIMIZU597476f2014-07-23 15:24:10 -07001package net.onrc.onos.core.newintent;
2
3import com.google.common.base.Objects;
4import com.google.common.collect.ImmutableList;
5import net.onrc.onos.api.intent.Intent;
6import net.onrc.onos.api.intent.IntentId;
7import net.onrc.onos.core.matchaction.action.IAction;
8import net.onrc.onos.core.matchaction.match.IMatch;
9import net.onrc.onos.core.util.SwitchPort;
10
11import java.util.List;
12
13import static com.google.common.base.Preconditions.checkNotNull;
14
15/**
16 * The class represents multiple sources, single destination tree like connectivity.
17 *
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070018 * <p>
Sho SHIMIZU597476f2014-07-23 15:24:10 -070019 * This class is intended to be used for the SDN-IP application.
Sho SHIMIZU9beddc02014-08-04 11:32:11 -070020 * </p>
Sho SHIMIZU597476f2014-07-23 15:24:10 -070021 */
22public class MultiPointToSinglePointIntent extends Intent {
23 private final ImmutableList<SwitchPort> ingressPorts;
24 private final SwitchPort egressPort;
25 private final IMatch match;
26 private final ImmutableList<IAction> modifications;
27
28 /**
29 * Constructs an intent representing multiple sources, single destination
30 * tree like connectivity.
31 *
32 * @param id the ID of the intent.
33 * @param ingressPorts the ingress ports.
34 * @param egressPort the egress port.
35 * @param match the filter condition of the incoming traffic which can go through.
36 * @param modifications the modification actions to the outgoing traffic.
37 */
38 public MultiPointToSinglePointIntent(IntentId id,
39 List<SwitchPort> ingressPorts,
40 SwitchPort egressPort,
41 IMatch match,
42 List<IAction> modifications) {
43 super(id);
44
45 this.ingressPorts = ImmutableList.copyOf(checkNotNull(ingressPorts));
46 this.egressPort = checkNotNull(egressPort);
47 this.match = checkNotNull(match);
48 this.modifications = ImmutableList.copyOf(checkNotNull(modifications));
49 }
50
51 /**
52 * Returns the ingress ports.
53 *
54 * @return the ingress ports.
55 */
56 public ImmutableList<SwitchPort> getIngressPorts() {
57 return ingressPorts;
58 }
59
60 /**
61 * Returns the egress port.
62 *
63 * @return the egress port.
64 */
65 public SwitchPort getEgressPort() {
66 return egressPort;
67 }
68
69 /**
70 * Returns the filter condition of the incoming traffic which can go through.
71 *
72 * @return the filter condition of the incoming traffic which can go through.
73 */
74 public IMatch getMatch() {
75 return match;
76 }
77
78 /**
79 * Returns the modification actions to the outgoing traffic.
80 *
81 * @return the modification actions to the outgoing traffic.
82 */
83 public ImmutableList<IAction> getModifications() {
84 return modifications;
85 }
86
87 @Override
88 public int hashCode() {
89 return Objects.hashCode(getId(), ingressPorts, egressPort, match, modifications);
90 }
91
92 @Override
93 public boolean equals(Object obj) {
94 if (obj == this) {
95 return true;
96 }
97
98 if (!(obj instanceof MultiPointToSinglePointIntent)) {
99 return false;
100 }
101
102 MultiPointToSinglePointIntent that = (MultiPointToSinglePointIntent) obj;
103 return Objects.equal(this.getId(), that.getId())
104 && Objects.equal(this.ingressPorts, that.ingressPorts)
105 && Objects.equal(this.egressPort, that.egressPort)
106 && Objects.equal(this.match, that.match)
107 && Objects.equal(this.modifications, that.modifications);
108 }
109
110 @Override
111 public String toString() {
112 return Objects.toStringHelper(this)
113 .add("id", getId())
114 .add("ingressPorts", ingressPorts)
115 .add("egressPort", egressPort)
116 .add("match", match)
117 .add("modifications", modifications)
118 .toString();
119 }
120}