blob: e5adc743c7a907ad1e1983e6e321c206f304497b [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 */
16
17package org.onosproject.driver.extensions;
18
19import org.onlab.util.KryoNamespace;
20import org.onosproject.net.flow.AbstractExtension;
21import org.onosproject.net.flow.criteria.ExtensionSelector;
22import org.onosproject.net.flow.criteria.ExtensionSelectorType;
23
24import java.util.Objects;
25
26/**
27 * OFDPA ALLOW_VLAN_TRANSLATION extension match.
28 */
29public class OfdpaMatchAllowVlanTranslation extends AbstractExtension implements ExtensionSelector {
30 private static final KryoNamespace APPKRYO = new KryoNamespace.Builder()
31 .register(Short.class)
32 .build();
33
34 private Short allowVlanTranslation;
35
36 /**
37 * OFDPA ALLOW_VLAN_TRANSLATION extension match.
38 */
39 public OfdpaMatchAllowVlanTranslation() {
40 allowVlanTranslation = 0;
41 }
42
43 /**
44 * Constructs new ALLOW_VLAN_TRANSLATION match with given boolean data.
45 *
46 * @param allowVlanTranslation allows vlan translation
47 */
48 public OfdpaMatchAllowVlanTranslation(Short allowVlanTranslation) {
49 this.allowVlanTranslation = allowVlanTranslation;
50 }
51
52 /**
53 * Gets allow vlan translation flag.
54 *
55 * @return allowVlanTranslation field
56 */
57 public Short allowVlanTranslation() {
58 return allowVlanTranslation;
59 }
60
61 @Override
62 public ExtensionSelectorType type() {
63 return ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_ALLOW_VLAN_TRANSLATION.type();
64 }
65
66 @Override
67 public byte[] serialize() {
68 return APPKRYO.serialize(allowVlanTranslation);
69 }
70
71 @Override
72 public void deserialize(byte[] data) {
73 allowVlanTranslation = APPKRYO.deserialize(data);
74 }
75
76 @Override
77 public int hashCode() {
78 return Objects.hashCode(allowVlanTranslation);
79 }
80
81 @Override
82 public boolean equals(Object obj) {
83 if (obj == this) {
84 return true;
85 }
86
87 if (obj == null || !obj.getClass().equals(OfdpaMatchAllowVlanTranslation.class)) {
88 return false;
89 }
90
91 OfdpaMatchAllowVlanTranslation that = (OfdpaMatchAllowVlanTranslation) obj;
92 return that.allowVlanTranslation().equals(allowVlanTranslation);
93 }
94}