Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.flow; |
| 18 | |
| 19 | import org.onosproject.net.flow.instructions.ExtensionPropertyException; |
| 20 | |
| 21 | import java.util.List; |
| 22 | |
| 23 | /** |
| 24 | * An extension to the northbound APIs. |
| 25 | */ |
| 26 | public interface Extension { |
| 27 | |
| 28 | /** |
| 29 | * Sets a property on the extension. |
| 30 | * |
| 31 | * @param key property key |
| 32 | * @param value value to set for the given key |
| 33 | * @param <T> class of the value |
| 34 | * @throws ExtensionPropertyException if the given key is not a valid |
| 35 | * property on this extension |
| 36 | */ |
| 37 | <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException; |
| 38 | |
| 39 | /** |
| 40 | * Gets a property value of an extension. |
| 41 | * |
| 42 | * @param key property key |
| 43 | * @param <T> class of the value |
| 44 | * @return value of the property |
| 45 | * @throws ExtensionPropertyException if the given key is not a valid |
| 46 | * property on this extension |
| 47 | */ |
| 48 | <T> T getPropertyValue(String key) throws ExtensionPropertyException; |
| 49 | |
| 50 | /** |
| 51 | * Gets a list of all properties on the extension. |
| 52 | * |
| 53 | * @return list of properties |
| 54 | */ |
| 55 | List<String> getProperties(); |
| 56 | |
| 57 | /** |
| 58 | * Serialize the extension to a byte array. |
| 59 | * |
| 60 | * @return byte array |
| 61 | */ |
| 62 | byte[] serialize(); |
| 63 | |
| 64 | /** |
| 65 | * Deserialize the extension from a byte array. The properties |
| 66 | * of this object will be overwritten with the data in the byte array. |
| 67 | * |
| 68 | * @param data input byte array |
| 69 | */ |
| 70 | void deserialize(byte[] data); |
| 71 | } |