blob: a05dd90f86c708650e5a72c6f19615c90e94a5f3 [file] [log] [blame]
Brian O'Connordee2e6b2014-08-12 11:34:51 -07001package net.onrc.onos.core.matchaction;
2
Ray Milkey9ed4b962014-08-20 15:43:40 -07003import java.util.Objects;
Ray Milkeyc127a5a2014-08-20 11:22:12 -07004
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 */
10public final class MatchActionOperationsId {
11
Ray Milkey9ed4b962014-08-20 15:43:40 -070012 private final long id;
Ray Milkeyc127a5a2014-08-20 11:22:12 -070013
14 /**
Ray Milkey9ed4b962014-08-20 15:43:40 -070015 * Constructs an Operations identifier and from a unique identifier.
Ray Milkeya313cde2014-09-05 09:02:52 -070016 *
17 * @param newId unique identifier to use for the new Id object
Ray Milkeyc127a5a2014-08-20 11:22:12 -070018 */
Ray Milkey9ed4b962014-08-20 15:43:40 -070019 public MatchActionOperationsId(final long newId) {
20 id = newId;
Ray Milkeyc127a5a2014-08-20 11:22:12 -070021 }
22
23 /**
Brian O'Connor0efc9062014-09-02 14:47:28 -070024 * no-arg instructor for Kryo.
25 */
26 protected MatchActionOperationsId() {
27 id = -1;
28 }
29
30 /**
Ray Milkeyc127a5a2014-08-20 11:22:12 -070031 * Gets the identifier for the Operations object.
32 *
33 * @return Operations object identifier as a string
34 */
Ray Milkey9ed4b962014-08-20 15:43:40 -070035 public long getId() {
Ray Milkeyc127a5a2014-08-20 11:22:12 -070036 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 Milkey9ed4b962014-08-20 15:43:40 -070049 final MatchActionOperationsId that = (MatchActionOperationsId) other;
Ray Milkeyc127a5a2014-08-20 11:22:12 -070050
Ray Milkey9ed4b962014-08-20 15:43:40 -070051 return this.getId() == that.getId();
Ray Milkeyc127a5a2014-08-20 11:22:12 -070052 }
53
54 @Override
55 public int hashCode() {
Ray Milkey9ed4b962014-08-20 15:43:40 -070056 return Objects.hashCode(id);
Ray Milkeyc127a5a2014-08-20 11:22:12 -070057 }
Brian O'Connordee2e6b2014-08-12 11:34:51 -070058}