Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent; |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 2 | |
| 3 | /** |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 4 | * This class is merely an Intent and an associated operation. |
| 5 | * <p> |
| 6 | * It exists so that the pair can be serialized for notifications and persistence. |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 7 | */ |
| 8 | public class IntentOperation { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 9 | public enum Operator { |
| 10 | /** |
| 11 | * Add new intent specified by intent field. |
| 12 | */ |
| 13 | ADD, |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 14 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 15 | /** |
| 16 | * Remove existing intent specified by intent field. |
| 17 | * The instance of intent field should be an instance of Intent class (not a child class) |
| 18 | */ |
| 19 | REMOVE, |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 20 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 21 | /** |
| 22 | * Do error handling. |
| 23 | * The instance of intent field should be an instance of ErrorIntent |
| 24 | */ |
| 25 | ERROR, |
| 26 | } |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 27 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 28 | public Operator operator; |
| 29 | public Intent intent; |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 30 | |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Default Constructor. |
| 33 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 34 | protected IntentOperation() { |
| 35 | } |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 36 | |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Constructor. |
| 39 | * |
| 40 | * @param operator the operation to perform for this Intent |
| 41 | * @param intent the Intent |
| 42 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 43 | public IntentOperation(Operator operator, Intent intent) { |
| 44 | this.operator = operator; |
| 45 | this.intent = intent; |
| 46 | } |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 47 | |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 48 | /** |
| 49 | * Returns a string representation of the operation and Intent. |
| 50 | * |
| 51 | * @return "operator, (Intent ID)" |
| 52 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 53 | @Override |
| 54 | public String toString() { |
| 55 | return operator.toString() + ", (" + intent.toString() + ")"; |
| 56 | } |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 57 | } |