xinwu | c1b011d | 2013-09-18 15:24:04 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.types; |
| 2 | |
xinwu | 3203443 | 2013-09-18 17:17:50 -0700 | [diff] [blame] | 3 | import javax.annotation.concurrent.Immutable; |
xinwu | c1b011d | 2013-09-18 15:24:04 -0700 | [diff] [blame] | 4 | |
| 5 | @Immutable |
xinwu | 3203443 | 2013-09-18 17:17:50 -0700 | [diff] [blame] | 6 | public class L2MulticastId { |
xinwu | c1b011d | 2013-09-18 15:24:04 -0700 | [diff] [blame] | 7 | static final int LENGTH = 4; |
| 8 | private final int rawValue; |
| 9 | |
xinwu | c1b011d | 2013-09-18 15:24:04 -0700 | [diff] [blame] | 10 | private L2MulticastId(final int rawValue) { |
| 11 | this.rawValue = rawValue; |
| 12 | } |
| 13 | |
| 14 | public static L2MulticastId of(final int raw) { |
| 15 | return new L2MulticastId(raw); |
| 16 | } |
| 17 | |
| 18 | public int getInt() { |
| 19 | return rawValue; |
| 20 | } |
| 21 | |
xinwu | c1b011d | 2013-09-18 15:24:04 -0700 | [diff] [blame] | 22 | public int getLength() { |
| 23 | return LENGTH; |
| 24 | } |
| 25 | |
| 26 | @Override |
| 27 | public int hashCode() { |
| 28 | final int prime = 31; |
| 29 | int result = 1; |
| 30 | result = prime * result + rawValue; |
| 31 | return result; |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public boolean equals(Object obj) { |
| 36 | if (this == obj) |
| 37 | return true; |
| 38 | if (obj == null) |
| 39 | return false; |
| 40 | if (getClass() != obj.getClass()) |
| 41 | return false; |
| 42 | L2MulticastId other = (L2MulticastId) obj; |
| 43 | if (rawValue != other.rawValue) |
| 44 | return false; |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public String toString() { |
| 50 | return Integer.toString(rawValue); |
| 51 | } |
xinwu | c1b011d | 2013-09-18 15:24:04 -0700 | [diff] [blame] | 52 | } |