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