Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction; |
| 2 | |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 3 | import net.onrc.onos.api.batchoperation.BatchOperationTarget; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 4 | |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 5 | import java.util.Objects; |
| 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 | |
| 22 | @Override |
| 23 | public String toString() { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 24 | return Long.toString(value); |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | @Override |
| 28 | public int hashCode() { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 29 | return Objects.hashCode(value); |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | @Override |
| 33 | public boolean equals(Object obj) { |
| 34 | if (obj instanceof MatchActionId) { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 35 | final MatchActionId that = (MatchActionId) obj; |
| 36 | return this.value == that.value; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 37 | } |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | } |