Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.intent; |
| 2 | |
| 3 | import net.onrc.onos.api.batchoperation.BatchOperationTargetId; |
| 4 | |
Sho SHIMIZU | ec4f5a7 | 2014-07-21 18:21:23 -0700 | [diff] [blame^] | 5 | /** |
| 6 | * The class representing intent's ID. |
| 7 | * |
| 8 | * This class is immutable. |
| 9 | */ |
| 10 | public final class IntentId extends BatchOperationTargetId { |
| 11 | private final long id; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 12 | |
Sho SHIMIZU | ec4f5a7 | 2014-07-21 18:21:23 -0700 | [diff] [blame^] | 13 | /** |
| 14 | * Constructs the ID corresponding to a given long value. |
| 15 | * |
| 16 | * In the future, this constructor will not be exposed to avoid misuses. |
| 17 | * |
| 18 | * @param id the underlay value of this ID. |
| 19 | */ |
| 20 | public IntentId(long id) { |
| 21 | this.id = id; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | @Override |
| 25 | public int hashCode() { |
Sho SHIMIZU | ec4f5a7 | 2014-07-21 18:21:23 -0700 | [diff] [blame^] | 26 | return (int) (id ^ (id >>> 32)); |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public boolean equals(Object obj) { |
Sho SHIMIZU | ec4f5a7 | 2014-07-21 18:21:23 -0700 | [diff] [blame^] | 31 | if (obj == this) { |
| 32 | return true; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 33 | } |
Sho SHIMIZU | ec4f5a7 | 2014-07-21 18:21:23 -0700 | [diff] [blame^] | 34 | |
| 35 | if (!(obj instanceof IntentId)) { |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | IntentId that = (IntentId) obj; |
| 40 | return this.id == that.id; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public String toString() { |
| 45 | return "0x" + Long.toHexString(id); |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 46 | } |
| 47 | } |