Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -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; |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 4 | |
| 5 | /** |
| 6 | * Identifier for a MatchActionOperations object. This is an immutable class |
| 7 | * that encapsulates a globally unique identifier for the MatchActionOperations |
| 8 | * object. |
| 9 | */ |
| 10 | public final class MatchActionOperationsId { |
| 11 | |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 12 | private final long id; |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 13 | |
| 14 | /** |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 15 | * Constructs an Operations identifier and from a unique identifier. |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame^] | 16 | * |
| 17 | * @param newId unique identifier to use for the new Id object |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 18 | */ |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 19 | public MatchActionOperationsId(final long newId) { |
| 20 | id = newId; |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | /** |
Brian O'Connor | 0efc906 | 2014-09-02 14:47:28 -0700 | [diff] [blame] | 24 | * no-arg instructor for Kryo. |
| 25 | */ |
| 26 | protected MatchActionOperationsId() { |
| 27 | id = -1; |
| 28 | } |
| 29 | |
| 30 | /** |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 31 | * Gets the identifier for the Operations object. |
| 32 | * |
| 33 | * @return Operations object identifier as a string |
| 34 | */ |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 35 | public long getId() { |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 36 | return id; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public boolean equals(final Object other) { |
| 41 | if (other == this) { |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | if (!(other instanceof MatchActionOperationsId)) { |
| 46 | return false; |
| 47 | } |
| 48 | |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 49 | final MatchActionOperationsId that = (MatchActionOperationsId) other; |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 50 | |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 51 | return this.getId() == that.getId(); |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public int hashCode() { |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 56 | return Objects.hashCode(id); |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 57 | } |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 58 | } |