blob: 0bddffa436d38cca4c926b55140998746a17e133 [file] [log] [blame]
Toshio Koide025a9152014-07-21 11:00:34 -07001package net.onrc.onos.core.matchaction;
2
Ray Milkey9ed4b962014-08-20 15:43:40 -07003import java.util.Objects;
4
Brian O'Connoraa5a7b92014-08-29 14:45:18 -07005import net.onrc.onos.api.batchoperation.BatchOperationTarget;
6
Ray Milkeyc127a5a2014-08-20 11:22:12 -07007/**
8 * A unique identifier for a MatchAction. Objects of this class are immutable.
9 */
Brian O'Connordee2e6b2014-08-12 11:34:51 -070010public final class MatchActionId implements BatchOperationTarget {
Ray Milkey9ed4b962014-08-20 15:43:40 -070011 private final long value;
Toshio Koide025a9152014-07-21 11:00:34 -070012
Ray Milkeyc127a5a2014-08-20 11:22:12 -070013 /**
14 * Creates a new Match Action Identifier based on the given id string.
15 *
16 * @param id unique id string
17 */
Ray Milkey9ed4b962014-08-20 15:43:40 -070018 public MatchActionId(long id) {
Toshio Koide025a9152014-07-21 11:00:34 -070019 value = id;
20 }
21
Brian O'Connoraa5a7b92014-08-29 14:45:18 -070022 /**
23 * Returns the MatchActionId as a long.
24 *
25 * @return MatchAction ID
26 */
27 public long value() {
28 return value;
29 }
30
Toshio Koide025a9152014-07-21 11:00:34 -070031 @Override
32 public String toString() {
Ray Milkey9ed4b962014-08-20 15:43:40 -070033 return Long.toString(value);
Toshio Koide025a9152014-07-21 11:00:34 -070034 }
35
36 @Override
37 public int hashCode() {
Ray Milkey9ed4b962014-08-20 15:43:40 -070038 return Objects.hashCode(value);
Toshio Koide025a9152014-07-21 11:00:34 -070039 }
40
41 @Override
42 public boolean equals(Object obj) {
43 if (obj instanceof MatchActionId) {
Ray Milkey9ed4b962014-08-20 15:43:40 -070044 final MatchActionId that = (MatchActionId) obj;
45 return this.value == that.value;
Toshio Koide025a9152014-07-21 11:00:34 -070046 }
47 return false;
48 }
49
50}