jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 1 | package org.onosproject.net.flow; |
| 2 | |
| 3 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 4 | |
| 5 | import java.util.Arrays; |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 6 | |
| 7 | /** |
| 8 | * Represents for 3rd-party private original flow. |
| 9 | */ |
| 10 | public final class FlowRuleExtPayLoad { |
| 11 | private final byte[] payLoad; |
| 12 | |
| 13 | /** |
| 14 | * private constructor. |
| 15 | * |
| 16 | * @param payLoad private flow |
| 17 | */ |
| 18 | private FlowRuleExtPayLoad(byte[] payLoad) { |
| 19 | this.payLoad = payLoad; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Creates a FlowRuleExtPayLoad. |
| 24 | * |
Thomas Vachuska | ca540c3 | 2015-04-22 21:24:19 -0700 | [diff] [blame] | 25 | * @param payLoad payload byte data |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 26 | * @return FlowRuleExtPayLoad payLoad |
| 27 | */ |
| 28 | public static FlowRuleExtPayLoad flowRuleExtPayLoad(byte[] payLoad) { |
| 29 | return new FlowRuleExtPayLoad(payLoad); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Returns private flow. |
| 34 | * |
| 35 | * @return payLoad private flow |
| 36 | */ |
| 37 | public byte[] payLoad() { |
| 38 | return payLoad; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public int hashCode() { |
Sho SHIMIZU | c9d8d0a | 2015-09-09 14:09:26 -0700 | [diff] [blame] | 43 | return Arrays.hashCode(payLoad); |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | public int hash() { |
Sho SHIMIZU | c9d8d0a | 2015-09-09 14:09:26 -0700 | [diff] [blame] | 47 | return Arrays.hashCode(payLoad); |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public boolean equals(Object obj) { |
| 52 | if (this == obj) { |
| 53 | return true; |
| 54 | } |
| 55 | if (obj instanceof FlowRuleExtPayLoad) { |
| 56 | FlowRuleExtPayLoad that = (FlowRuleExtPayLoad) obj; |
| 57 | return Arrays.equals(payLoad, that.payLoad); |
| 58 | |
| 59 | } |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public String toString() { |
| 65 | return toStringHelper(this).add("payLoad", payLoad).toString(); |
| 66 | } |
| 67 | } |