blob: fa98b6def95f290a3ae0d223bb4b18869afc5428 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * 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
7 *
8 * 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.
15 */
16package org.onosproject.net.flowobjective;
17
18import org.onosproject.core.ApplicationId;
19
alshabib2a441c62015-04-13 18:39:38 -070020import java.util.Optional;
21
alshabibfaa1e362015-04-02 15:01:54 -070022/**
23 * Base representation of an flow description.
24 */
25public interface Objective {
26
27 static final boolean DEFAULT_PERMANENT = true;
28 static final int DEFAULT_TIMEOUT = 0;
29 static final int DEFAULT_PRIORITY = 32768;
30
31 /**
32 * Type of operation.
33 */
34 enum Operation {
35 /**
36 * Adds the objective.
37 */
38 ADD,
39
40 /**
41 * Removes the objective.
42 */
43 REMOVE
44 }
45
46 /**
47 * An identifier for this objective.
48 *
49 * @return an integer
50 */
51 int id();
52
53 /**
54 * The priority for this objective.
55 *
56 * @return an integer
57 */
58 int priority();
59
60 /**
61 * The application which applied this objective.
62 *
63 * @return an application id
64 */
65 ApplicationId appId();
66
67 /**
68 * The timeout for this objective.
69 *
70 * @return an integer
71 */
72 int timeout();
73
74 /**
75 * Whether this objective is permanent.
76 *
77 * @return a boolean
78 */
79 boolean permanent();
80
81 /**
82 * The type of operation for this objective.
83 *
84 * @return an operation
85 */
86 Operation op();
87
88 /**
alshabib2a441c62015-04-13 18:39:38 -070089 * Obtains an optional context.
90 *
91 * @return optional; which will be empty if there is no context.
92 * Otherwise it will return the context.
93 */
94 Optional<ObjectiveContext> context();
95
96 /**
alshabibfaa1e362015-04-02 15:01:54 -070097 * An objective builder.
98 */
99 public interface Builder {
100 /**
101 * Makes the filtering objective temporary.
102 *
103 * @param timeout a timeout
104 * @return an objective builder
105 */
106 public Builder makeTemporary(int timeout);
107
108 /**
109 * Makes the filtering objective permanent.
110 *
111 * @return an objective builder
112 */
113 public Builder makePermanent();
114
115 /**
116 * Specifies the application which applied the filter.
117 *
118 * @param appId an application id
119 * @return an objective builder
120 */
121 public Builder fromApp(ApplicationId appId);
122
123 /**
124 * Sets the priority for this objective.
125 *
126 * @param priority an integer
127 * @return an objective builder
128 */
129 public Builder withPriority(int priority);
130 }
131
132}