blob: 93f2ec7abd7781aa1449c5c188b25a90cd3db221 [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 Milkeyc127a5a2014-08-20 11:22:12 -070016 */
Ray Milkey9ed4b962014-08-20 15:43:40 -070017 public MatchActionOperationsId(final long newId) {
18 id = newId;
Ray Milkeyc127a5a2014-08-20 11:22:12 -070019 }
20
21 /**
Brian O'Connor0efc9062014-09-02 14:47:28 -070022 * no-arg instructor for Kryo.
23 */
24 protected MatchActionOperationsId() {
25 id = -1;
26 }
27
28 /**
Ray Milkeyc127a5a2014-08-20 11:22:12 -070029 * Gets the identifier for the Operations object.
30 *
31 * @return Operations object identifier as a string
32 */
Ray Milkey9ed4b962014-08-20 15:43:40 -070033 public long getId() {
Ray Milkeyc127a5a2014-08-20 11:22:12 -070034 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 Milkey9ed4b962014-08-20 15:43:40 -070047 final MatchActionOperationsId that = (MatchActionOperationsId) other;
Ray Milkeyc127a5a2014-08-20 11:22:12 -070048
Ray Milkey9ed4b962014-08-20 15:43:40 -070049 return this.getId() == that.getId();
Ray Milkeyc127a5a2014-08-20 11:22:12 -070050 }
51
52 @Override
53 public int hashCode() {
Ray Milkey9ed4b962014-08-20 15:43:40 -070054 return Objects.hashCode(id);
Ray Milkeyc127a5a2014-08-20 11:22:12 -070055 }
Brian O'Connordee2e6b2014-08-12 11:34:51 -070056}