blob: d645f1291e33257ad52f4e76e6c7a7121c11b3ad [file] [log] [blame]
Andreas Pantelopoulosfdcfe532018-04-02 10:59:23 -07001/*
2 * Copyright 2018-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 */
16package org.onosproject.driver.extensions;
17
18import com.google.common.base.MoreObjects;
19import org.onlab.util.KryoNamespace;
20import org.onosproject.net.PortNumber;
21import org.onosproject.net.flow.AbstractExtension;
22import org.onosproject.net.flow.criteria.ExtensionSelector;
23import org.onosproject.net.flow.criteria.ExtensionSelectorType;
24
25import java.util.Objects;
26
27import static com.google.common.base.Preconditions.checkNotNull;
28
29/**
30 * OFDPA ACTSET_OUTPUT extension match.
31 */
32public class OfdpaMatchActsetOutput extends AbstractExtension implements ExtensionSelector {
33
34 private PortNumber port;
35 private static final KryoNamespace APPKRYO = new KryoNamespace.Builder()
36 .register(PortNumber.class)
37 .build();
38
39 /**
40 * OFDPA ACTSET_OUTPUT extension match.
41 */
42 public OfdpaMatchActsetOutput() {
43 this.port = null;
44 }
45
46 /**
47 * Constructs new ACTSET_OUTPUT match with given port number.
48 *
49 * @param port port number
50 */
51 public OfdpaMatchActsetOutput(PortNumber port) {
52 checkNotNull(port);
53 this.port = port;
54 }
55
56 /**
57 * Gets the port number.
58 *
59 * @return the port number
60 */
61 public PortNumber port() {
62 return port;
63 }
64
65 @Override
66 public ExtensionSelectorType type() {
67 return ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_ACTSET_OUTPUT.type();
68 }
69
70 @Override
71 public byte[] serialize() {
72 return APPKRYO.serialize(port);
73 }
74
75 @Override
76 public void deserialize(byte[] data) {
77 port = APPKRYO.deserialize(data);
78 }
79
80 @Override
81 public int hashCode() {
82 return Objects.hashCode(port);
83 }
84
85 @Override
86 public boolean equals(Object obj) {
87
88 if (this == obj) {
89 return true;
90 }
91
92 if (obj == null || !obj.getClass().equals(OfdpaMatchActsetOutput.class)) {
93 return false;
94 }
95
96 OfdpaMatchActsetOutput that = (OfdpaMatchActsetOutput) obj;
97 return port.equals(that.port());
98 }
99
100 @Override
101 public String toString() {
102 return MoreObjects.toStringHelper(getClass())
103 .add("port", port)
104 .toString();
105 }
106}