blob: 59579a51f8f0db2959609c8854c39ca6bdee3417 [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 /**
Brian O'Connor0efc9062014-09-02 14:47:28 -070023 * no-arg constructor for Kryo.
24 */
25 protected MatchActionId() {
26 value = -1;
27 }
28
29 /**
Brian O'Connoraa5a7b92014-08-29 14:45:18 -070030 * Returns the MatchActionId as a long.
31 *
32 * @return MatchAction ID
33 */
Ray Milkeya313cde2014-09-05 09:02:52 -070034 public long getValue() {
Brian O'Connoraa5a7b92014-08-29 14:45:18 -070035 return value;
36 }
37
Toshio Koide025a9152014-07-21 11:00:34 -070038 @Override
39 public String toString() {
Ray Milkey9ed4b962014-08-20 15:43:40 -070040 return Long.toString(value);
Toshio Koide025a9152014-07-21 11:00:34 -070041 }
42
43 @Override
44 public int hashCode() {
Ray Milkey9ed4b962014-08-20 15:43:40 -070045 return Objects.hashCode(value);
Toshio Koide025a9152014-07-21 11:00:34 -070046 }
47
48 @Override
49 public boolean equals(Object obj) {
50 if (obj instanceof MatchActionId) {
Ray Milkey9ed4b962014-08-20 15:43:40 -070051 final MatchActionId that = (MatchActionId) obj;
52 return this.value == that.value;
Toshio Koide025a9152014-07-21 11:00:34 -070053 }
54 return false;
55 }
56
57}