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