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