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