blob: 902f41894b326d4d95eab0889057efad022790ff [file] [log] [blame]
Thomas Vachuska1fb982f2014-10-22 14:09:17 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska1fb982f2014-10-22 14:09:17 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska1fb982f2014-10-22 14:09:17 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska1fb982f2014-10-22 14:09:17 -070015 */
16package org.onlab.onos.net.intent;
17
18/**
19 * Abstraction of an intent-related operation, e.g. add, remove, replace.
20 */
21public class IntentOperation {
22
23 private final Type type;
24 private final IntentId intentId;
25 private final Intent intent;
26
27 /**
28 * Operation type.
29 */
30 enum Type {
31 /**
32 * Indicates that an intent should be added.
33 */
34 SUBMIT,
35
36 /**
37 * Indicates that an intent should be removed.
38 */
39 WITHDRAW,
40
41 /**
42 * Indicates that an intent should be replaced with another.
43 */
44 REPLACE
45 }
46
47 /**
48 * Creates an intent operation.
49 *
50 * @param type operation type
51 * @param intentId identifier of the intent subject to the operation
52 * @param intent intent subject
53 */
54 IntentOperation(Type type, IntentId intentId, Intent intent) {
55 this.type = type;
56 this.intentId = intentId;
57 this.intent = intent;
58 }
59
60 /**
61 * Returns the type of the operation.
62 *
63 * @return operation type
64 */
65 public Type type() {
66 return type;
67 }
68
69 /**
70 * Returns the identifier of the intent to which this operation applies.
71 *
72 * @return intent identifier
73 */
74 public IntentId intentId() {
75 return intentId;
76 }
77
78 /**
79 * Returns the intent to which this operation applied. For remove,
80 * this can be null.
81 *
82 * @return intent that is the subject of the operation; null for remove
83 */
84 public Intent intent() {
85 return intent;
86 }
87
88}