blob: 22bf95c9037ef87f76028ac397f8363a5af6a5f5 [file] [log] [blame]
Frank Wang72c5e432016-09-23 17:20:49 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Frank Wang72c5e432016-09-23 17:20:49 +08003 *
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.flow.criteria;
17
18import org.onosproject.net.flow.AbstractExtension;
19import java.util.Arrays;
Frank Wang72c5e432016-09-23 17:20:49 +080020import static com.google.common.base.MoreObjects.toStringHelper;
21
22
23/**
24 * Unresolved extension selector.
25 */
26public class UnresolvedExtensionSelector extends AbstractExtension implements ExtensionSelector {
27
28 private byte[] bytes;
29 private ExtensionSelectorType unresolvedSelectorType;
30
31 /**
32 * Creates a new unresolved extension selector with given data in byte form.
33 *
Ray Milkeyef794342016-11-09 16:20:29 -080034 * @param arraybyte byte data for the extension selector
Frank Wang72c5e432016-09-23 17:20:49 +080035 * @param type unresolved extension data type
36 */
37 public UnresolvedExtensionSelector(byte[] arraybyte, ExtensionSelectorType type) {
38 this.bytes = arraybyte;
39 this.unresolvedSelectorType = type;
40 }
41
42 @Override
43 public byte[] serialize() {
44 return bytes;
45 }
46
47 @Override
48 public void deserialize(byte[] data) {
49 bytes = data;
50 }
51
52 @Override
53 public ExtensionSelectorType type() {
54 return ExtensionSelectorType.ExtensionSelectorTypes.UNRESOLVED_TYPE.type();
55 }
56
57 @Override
58 public int hashCode() {
Yuta HIGUCHIfbd9ae92018-01-24 23:39:06 -080059 return Arrays.hashCode(bytes);
Frank Wang72c5e432016-09-23 17:20:49 +080060 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj) {
65 return true;
66 }
67 if (obj instanceof UnresolvedExtensionSelector) {
68 UnresolvedExtensionSelector that = (UnresolvedExtensionSelector) obj;
69 return Arrays.equals(bytes, that.bytes);
70 }
71 return false;
72 }
73
74 @Override
75 public String toString() {
76 return toStringHelper(type().toString())
77 .add("bytes", bytes)
78 .add("unresolvedSelectorType", unresolvedSelectorType)
79 .toString();
80 }
81}
82