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