Thomas Vachuska | 84922b3 | 2016-02-18 13:52:11 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Thomas Vachuska | 84922b3 | 2016-02-18 13:52:11 -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.device; |
| 18 | |
| 19 | import org.onosproject.net.driver.HandlerBehaviour; |
| 20 | |
| 21 | import java.util.List; |
DongRyeol Cha | 5f6f04a | 2020-01-13 17:06:34 +0900 | [diff] [blame] | 22 | import java.util.function.Consumer; |
Thomas Vachuska | 84922b3 | 2016-02-18 13:52:11 -0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Handler behaviour capable of creating device and port descriptions. |
| 26 | * These descriptions should be appropriately annotated to support downstream |
| 27 | * projections of the respective devices and their ports. |
| 28 | */ |
| 29 | public interface DeviceDescriptionDiscovery extends HandlerBehaviour { |
| 30 | |
| 31 | /** |
Andrea Campanella | 6c71a05 | 2016-04-22 11:56:31 -0700 | [diff] [blame] | 32 | * Returns a device description appropriately annotated to support |
Thomas Vachuska | 84922b3 | 2016-02-18 13:52:11 -0800 | [diff] [blame] | 33 | * downstream model extension via projections of the resulting device, |
| 34 | * as in the following example. |
| 35 | * <pre> |
| 36 | * MicrowaveDevice device = deviceService.get(id).as(MicrowaveDevice.class); |
| 37 | * </pre> |
| 38 | * |
| 39 | * @return annotated device description |
| 40 | */ |
| 41 | DeviceDescription discoverDeviceDetails(); |
| 42 | |
| 43 | /** |
Andrea Campanella | 6c71a05 | 2016-04-22 11:56:31 -0700 | [diff] [blame] | 44 | * Returns a list of port descriptions appropriately annotated to support |
Thomas Vachuska | 84922b3 | 2016-02-18 13:52:11 -0800 | [diff] [blame] | 45 | * downstream model extension via projections of their parent device, |
| 46 | * as in the following example. |
| 47 | * <pre> |
| 48 | * MicrowaveDevice device = deviceService.get(id).as(MicrowaveDevice.class); |
| 49 | * List<MicrowavePort> ports = device.microwavePorts(deviceService.getPorts(id)); |
| 50 | * </pre> |
| 51 | * |
| 52 | * @return annotated device description |
| 53 | */ |
| 54 | List<PortDescription> discoverPortDetails(); |
| 55 | |
DongRyeol Cha | 5f6f04a | 2020-01-13 17:06:34 +0900 | [diff] [blame] | 56 | /** |
| 57 | * Invoke given lamda function when port descriptions are discovered. |
| 58 | * |
| 59 | * @param consumer consumer to process port description |
| 60 | */ |
| 61 | default void discoverPortDetails(Consumer<PortDescription> consumer) { |
| 62 | throw new UnsupportedOperationException("Need to be implemented by subclass"); |
| 63 | } |
Thomas Vachuska | 84922b3 | 2016-02-18 13:52:11 -0800 | [diff] [blame] | 64 | } |