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