blob: 4ec3e6a98d39e8df06566a10fca094a0032276b6 [file] [log] [blame]
Toshio Koide025a9152014-07-21 11:00:34 -07001package net.onrc.onos.api.intent;
2
3import net.onrc.onos.api.batchoperation.BatchOperationTargetId;
4
Sho SHIMIZUec4f5a72014-07-21 18:21:23 -07005/**
6 * The class representing intent's ID.
7 *
8 * This class is immutable.
9 */
10public final class IntentId extends BatchOperationTargetId {
11 private final long id;
Toshio Koide025a9152014-07-21 11:00:34 -070012
Sho SHIMIZUec4f5a72014-07-21 18:21:23 -070013 /**
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 Koide025a9152014-07-21 11:00:34 -070022 }
23
24 @Override
25 public int hashCode() {
Sho SHIMIZUec4f5a72014-07-21 18:21:23 -070026 return (int) (id ^ (id >>> 32));
Toshio Koide025a9152014-07-21 11:00:34 -070027 }
28
29 @Override
30 public boolean equals(Object obj) {
Sho SHIMIZUec4f5a72014-07-21 18:21:23 -070031 if (obj == this) {
32 return true;
Toshio Koide025a9152014-07-21 11:00:34 -070033 }
Sho SHIMIZUec4f5a72014-07-21 18:21:23 -070034
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 Koide025a9152014-07-21 11:00:34 -070046 }
47}