Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.device; |
tom | 61359e9 | 2014-09-16 15:50:27 -0700 | [diff] [blame] | 17 | |
Bri Prebilic Cole | 09e464b | 2015-01-07 17:13:54 -0800 | [diff] [blame] | 18 | import com.google.common.base.Predicate; |
| 19 | import com.google.common.collect.FluentIterable; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.Device; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.MastershipRole; |
| 23 | import org.onosproject.net.Port; |
| 24 | import org.onosproject.net.PortNumber; |
tom | 61359e9 | 2014-09-16 15:50:27 -0700 | [diff] [blame] | 25 | |
| 26 | import java.util.List; |
| 27 | |
| 28 | /** |
| 29 | * Test adapter for device service. |
| 30 | */ |
| 31 | public class DeviceServiceAdapter implements DeviceService { |
| 32 | @Override |
| 33 | public int getDeviceCount() { |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public Iterable<Device> getDevices() { |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | @Override |
Yuta HIGUCHI | f1f2ac0 | 2014-11-26 14:02:22 -0800 | [diff] [blame] | 43 | public Iterable<Device> getAvailableDevices() { |
| 44 | return FluentIterable.from(getDevices()) |
| 45 | .filter(new Predicate<Device>() { |
| 46 | |
| 47 | @Override |
| 48 | public boolean apply(Device input) { |
| 49 | return isAvailable(input.id()); |
| 50 | } |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | @Override |
tom | 61359e9 | 2014-09-16 15:50:27 -0700 | [diff] [blame] | 55 | public Device getDevice(DeviceId deviceId) { |
| 56 | return null; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public MastershipRole getRole(DeviceId deviceId) { |
| 61 | return null; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public List<Port> getPorts(DeviceId deviceId) { |
| 66 | return null; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public Port getPort(DeviceId deviceId, PortNumber portNumber) { |
| 71 | return null; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean isAvailable(DeviceId deviceId) { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public void addListener(DeviceListener listener) { |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public void removeListener(DeviceListener listener) { |
| 85 | } |
| 86 | |
| 87 | } |