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