blob: d4d2d9eca5facce46428e80064e4298347c6b838 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -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 */
jcc3d4e14a2015-04-21 11:32:05 +080016package org.onosproject.net.flow;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Arrays;
jcc3d4e14a2015-04-21 11:32:05 +080021
22/**
23 * Represents for 3rd-party private original flow.
24 */
25public final class FlowRuleExtPayLoad {
26 private final byte[] payLoad;
27
28 /**
29 * private constructor.
30 *
31 * @param payLoad private flow
32 */
33 private FlowRuleExtPayLoad(byte[] payLoad) {
34 this.payLoad = payLoad;
35 }
36
37 /**
38 * Creates a FlowRuleExtPayLoad.
39 *
Thomas Vachuskaca540c32015-04-22 21:24:19 -070040 * @param payLoad payload byte data
jcc3d4e14a2015-04-21 11:32:05 +080041 * @return FlowRuleExtPayLoad payLoad
42 */
43 public static FlowRuleExtPayLoad flowRuleExtPayLoad(byte[] payLoad) {
44 return new FlowRuleExtPayLoad(payLoad);
45 }
46
47 /**
48 * Returns private flow.
49 *
50 * @return payLoad private flow
51 */
52 public byte[] payLoad() {
53 return payLoad;
54 }
55
56 @Override
57 public int hashCode() {
Sho SHIMIZUc9d8d0a2015-09-09 14:09:26 -070058 return Arrays.hashCode(payLoad);
jcc3d4e14a2015-04-21 11:32:05 +080059 }
60
61 public int hash() {
Sho SHIMIZUc9d8d0a2015-09-09 14:09:26 -070062 return Arrays.hashCode(payLoad);
jcc3d4e14a2015-04-21 11:32:05 +080063 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (this == obj) {
68 return true;
69 }
70 if (obj instanceof FlowRuleExtPayLoad) {
71 FlowRuleExtPayLoad that = (FlowRuleExtPayLoad) obj;
72 return Arrays.equals(payLoad, that.payLoad);
73
74 }
75 return false;
76 }
77
78 @Override
79 public String toString() {
80 return toStringHelper(this).add("payLoad", payLoad).toString();
81 }
82}