blob: 5233e262cec06983f1f550932be76b5f63eee407 [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent;
Toshio Koideb609b3b2014-02-14 18:25:52 -08002
3/**
Brian O'Connora581b9d2014-06-15 23:32:36 -07004 * 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 Koideb609b3b2014-02-14 18:25:52 -08007 */
8public class IntentOperation {
Ray Milkey269ffb92014-04-03 14:43:30 -07009 public enum Operator {
10 /**
11 * Add new intent specified by intent field.
12 */
13 ADD,
Toshio Koideb609b3b2014-02-14 18:25:52 -080014
Ray Milkey269ffb92014-04-03 14:43:30 -070015 /**
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 Koidedf2eab92014-02-20 11:24:59 -080020
Ray Milkey269ffb92014-04-03 14:43:30 -070021 /**
22 * Do error handling.
23 * The instance of intent field should be an instance of ErrorIntent
24 */
25 ERROR,
26 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080027
Ray Milkey269ffb92014-04-03 14:43:30 -070028 public Operator operator;
29 public Intent intent;
Toshio Koidea10c0372014-02-20 17:28:10 -080030
Brian O'Connora581b9d2014-06-15 23:32:36 -070031 /**
32 * Default Constructor.
33 */
Ray Milkey269ffb92014-04-03 14:43:30 -070034 protected IntentOperation() {
35 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080036
Brian O'Connora581b9d2014-06-15 23:32:36 -070037 /**
38 * Constructor.
39 *
40 * @param operator the operation to perform for this Intent
41 * @param intent the Intent
42 */
Ray Milkey269ffb92014-04-03 14:43:30 -070043 public IntentOperation(Operator operator, Intent intent) {
44 this.operator = operator;
45 this.intent = intent;
46 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080047
Brian O'Connora581b9d2014-06-15 23:32:36 -070048 /**
49 * Returns a string representation of the operation and Intent.
50 *
51 * @return "operator, (Intent ID)"
52 */
Ray Milkey269ffb92014-04-03 14:43:30 -070053 @Override
54 public String toString() {
55 return operator.toString() + ", (" + intent.toString() + ")";
56 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080057}