Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Arrays; |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Represents for 3rd-party private original flow. |
| 24 | */ |
| 25 | public 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 Vachuska | ca540c3 | 2015-04-22 21:24:19 -0700 | [diff] [blame] | 40 | * @param payLoad payload byte data |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 41 | * @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 SHIMIZU | c9d8d0a | 2015-09-09 14:09:26 -0700 | [diff] [blame] | 58 | return Arrays.hashCode(payLoad); |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | public int hash() { |
Sho SHIMIZU | c9d8d0a | 2015-09-09 14:09:26 -0700 | [diff] [blame] | 62 | return Arrays.hashCode(payLoad); |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 63 | } |
| 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 | } |