blob: 0efcc7f5c51970e9a823e874d77784227999e175 [file] [log] [blame]
alshabib42947782015-03-31 14:59:06 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.net.packet;
17
18import com.google.common.base.MoreObjects;
19import org.onosproject.core.ApplicationId;
20import org.onosproject.net.flow.FlowRule;
21import org.onosproject.net.flow.TrafficSelector;
22
23/**
24 * Default implementation of a packet request.
25 */
26public final class DefaultPacketRequest implements PacketRequest {
27 private final TrafficSelector selector;
28 private final PacketPriority priority;
29 private final ApplicationId appId;
30 private final FlowRule.Type tableType;
31
32 public DefaultPacketRequest(TrafficSelector selector, PacketPriority priority,
33 ApplicationId appId, FlowRule.Type tableType) {
34 this.selector = selector;
35 this.priority = priority;
36 this.appId = appId;
37 this.tableType = tableType;
38 }
39
40 public TrafficSelector selector() {
41 return selector;
42 }
43
44 public PacketPriority priority() {
45 return priority;
46 }
47
48 public ApplicationId appId() {
49 return appId;
50 }
51
52 public FlowRule.Type tableType() {
53 return tableType;
54 }
55
56 @Override
57 public boolean equals(Object o) {
58 if (this == o) {
59 return true;
60 }
61 if (o == null || getClass() != o.getClass()) {
62 return false;
63 }
64
65 DefaultPacketRequest that = (DefaultPacketRequest) o;
66
67 if (priority != that.priority) {
68 return false;
69 }
70 if (!selector.equals(that.selector)) {
71 return false;
72 }
73 if (!tableType.equals(that.tableType)) {
74 return false;
75 }
76
77 return true;
78 }
79
80 @Override
81 public int hashCode() {
82 int result = selector.hashCode();
83 result = 31 * result + priority.hashCode();
84 return result;
85 }
86
87 @Override
88 public String toString() {
89 return MoreObjects.toStringHelper(this.getClass())
90 .add("selector", selector)
91 .add("priority", priority)
92 .add("appId", appId)
93 .add("table-type", tableType).toString();
94 }
95}