Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction; |
| 2 | |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 3 | import java.util.Objects; |
| 4 | |
Brian O'Connor | aa5a7b9 | 2014-08-29 14:45:18 -0700 | [diff] [blame] | 5 | import net.onrc.onos.api.batchoperation.BatchOperationTarget; |
| 6 | |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 7 | /** |
| 8 | * A unique identifier for a MatchAction. Objects of this class are immutable. |
| 9 | */ |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 10 | public final class MatchActionId implements BatchOperationTarget { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 11 | private final long value; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 12 | |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 13 | /** |
| 14 | * Creates a new Match Action Identifier based on the given id string. |
| 15 | * |
| 16 | * @param id unique id string |
| 17 | */ |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 18 | public MatchActionId(long id) { |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 19 | value = id; |
| 20 | } |
| 21 | |
Brian O'Connor | aa5a7b9 | 2014-08-29 14:45:18 -0700 | [diff] [blame] | 22 | /** |
Brian O'Connor | 0efc906 | 2014-09-02 14:47:28 -0700 | [diff] [blame] | 23 | * no-arg constructor for Kryo. |
| 24 | */ |
| 25 | protected MatchActionId() { |
| 26 | value = -1; |
| 27 | } |
| 28 | |
| 29 | /** |
Brian O'Connor | aa5a7b9 | 2014-08-29 14:45:18 -0700 | [diff] [blame] | 30 | * Returns the MatchActionId as a long. |
| 31 | * |
| 32 | * @return MatchAction ID |
| 33 | */ |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 34 | public long getValue() { |
Brian O'Connor | aa5a7b9 | 2014-08-29 14:45:18 -0700 | [diff] [blame] | 35 | return value; |
| 36 | } |
| 37 | |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 38 | @Override |
| 39 | public String toString() { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 40 | return Long.toString(value); |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public int hashCode() { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 45 | return Objects.hashCode(value); |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public boolean equals(Object obj) { |
| 50 | if (obj instanceof MatchActionId) { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 51 | final MatchActionId that = (MatchActionId) obj; |
| 52 | return this.value == that.value; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 53 | } |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | } |