Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction; |
| 2 | |
| 3 | import net.onrc.onos.api.batchoperation.BatchOperation; |
| 4 | |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame^] | 5 | import static com.google.common.base.Preconditions.checkNotNull; |
| 6 | |
| 7 | /** |
| 8 | * The MatchActionOperations class holds a list of MatchActionOperationEntry |
| 9 | * objects to be executed together as one set. |
| 10 | * <p/> |
| 11 | * Objects of this class are immutable. |
| 12 | */ |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 13 | public final class MatchActionOperations |
| 14 | extends BatchOperation<MatchActionOperationEntry> { |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame^] | 15 | |
| 16 | private final MatchActionOperationsId id; |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 17 | /** |
| 18 | * The MatchAction operators. |
| 19 | */ |
| 20 | public enum Operator { |
| 21 | ADD, |
| 22 | REMOVE, |
| 23 | } |
| 24 | |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame^] | 25 | /** |
| 26 | * Constructs a MatchActionOperations object from an id. Internal |
| 27 | * constructor called by a public factory method. |
| 28 | * |
| 29 | * @param newId match action operations identifier for this instance |
| 30 | */ |
| 31 | private MatchActionOperations(final MatchActionOperationsId newId) { |
| 32 | id = checkNotNull(newId); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Creates a MatchActionOperations object from an id. |
| 37 | * |
| 38 | * @param newId match action operations identifier to use for the new object |
| 39 | * @return Match Action Operations object |
| 40 | */ |
| 41 | public static MatchActionOperations createMatchActionsOperations( |
| 42 | final MatchActionOperationsId newId) { |
| 43 | return new MatchActionOperations(newId); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Gets the identifier for the Match Action Operations object. |
| 48 | * |
| 49 | * @return identifier for the Opertions object |
| 50 | */ |
| 51 | public MatchActionOperationsId getOperationsId() { |
| 52 | return id; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public int hashCode() { |
| 57 | return id.hashCode(); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public boolean equals(Object obj) { |
| 62 | if (obj instanceof MatchActionOperations) { |
| 63 | final MatchActionOperations other = (MatchActionOperations) obj; |
| 64 | return (id.equals(other.id)); |
| 65 | } |
| 66 | return false; |
| 67 | } |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 68 | } |