blob: 74203af748588f98c52c14cea87a5ef18227159c [file] [log] [blame]
Andrea Campanella01e886e2017-12-15 15:27:31 +01001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.t3.api;
18
19import org.onosproject.net.ConnectPoint;
20import org.onosproject.net.flow.TrafficSelector;
21import org.onosproject.net.group.Group;
22
23import java.util.List;
Andrea Campanella79cb17d2018-02-27 18:03:17 +010024import java.util.Objects;
Andrea Campanella01e886e2017-12-15 15:27:31 +010025
26/**
27 * Class to represent the groups in a device for a given output and packet.
28 */
Andrea Campanella58b3b522018-02-06 15:46:52 +010029//FIXME consider name change.
Andrea Campanella01e886e2017-12-15 15:27:31 +010030public class GroupsInDevice {
31
32 private ConnectPoint output;
33 private List<Group> groups;
34 private TrafficSelector selector;
35
36 /**
37 * Saves the given groups for the output connect point and the selector.
Andrea Campanella58b3b522018-02-06 15:46:52 +010038 *
39 * @param output the output connect point
40 * @param groups the groups
Andrea Campanella01e886e2017-12-15 15:27:31 +010041 * @param selector the selector representing the final packet
42 */
43 public GroupsInDevice(ConnectPoint output, List<Group> groups, TrafficSelector selector) {
44
45 this.output = output;
46 this.groups = groups;
47 this.selector = selector;
48 }
49
50 /**
51 * Returns the output connect point.
Andrea Campanella58b3b522018-02-06 15:46:52 +010052 *
Andrea Campanella01e886e2017-12-15 15:27:31 +010053 * @return the connect point
54 */
55 public ConnectPoint getOutput() {
56 return output;
57 }
58
59 /**
60 * Returns the groups.
Andrea Campanella58b3b522018-02-06 15:46:52 +010061 *
Andrea Campanella01e886e2017-12-15 15:27:31 +010062 * @return groups.
63 */
64 public List<Group> getGroups() {
65 return groups;
66 }
67
68 /**
69 * Returns the final packet after traversing the network.
Andrea Campanella58b3b522018-02-06 15:46:52 +010070 *
Andrea Campanella01e886e2017-12-15 15:27:31 +010071 * @return the selector with packet info
72 */
73 public TrafficSelector getFinalPacket() {
74 return selector;
75 }
76
Andrea Campanella58b3b522018-02-06 15:46:52 +010077 /**
78 * Updates the final packet.
79 *
80 * @param updatedPacket the updated final packet
81 */
82 public void setFinalPacket(TrafficSelector updatedPacket) {
83 selector = updatedPacket;
84 }
85
Andrea Campanella01e886e2017-12-15 15:27:31 +010086 @Override
Andrea Campanella79cb17d2018-02-27 18:03:17 +010087 public boolean equals(Object o) {
88 if (this == o) {
89 return true;
90 }
91
92 if (o == null || getClass() != o.getClass()) {
93 return false;
94 }
95
96 GroupsInDevice that = (GroupsInDevice) o;
97
98 return Objects.equals(output, that.output) &&
99 Objects.equals(groups, that.groups) &&
100 Objects.equals(selector, that.selector);
101 }
102
103 @Override
104 public int hashCode() {
105 return Objects.hash(output, groups, selector);
106 }
107
108 @Override
Andrea Campanella01e886e2017-12-15 15:27:31 +0100109 public String toString() {
110 return "GroupsInDevice{" +
Andrea Campanella79cb17d2018-02-27 18:03:17 +0100111
Andrea Campanella01e886e2017-12-15 15:27:31 +0100112 "output=" + output +
113 ", groups=" + groups +
114 ", selector=" + selector +
115 '}';
116 }
117
118}