HIGUCHI Yuta | 34a3f69 | 2016-01-09 21:08:57 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
HIGUCHI Yuta | 34a3f69 | 2016-01-09 21:08:57 -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 | */ |
HIGUCHI Yuta | f46dc4f | 2016-05-13 11:24:13 -0700 | [diff] [blame] | 16 | package org.onosproject.net.utils; |
HIGUCHI Yuta | 34a3f69 | 2016-01-09 21:08:57 -0800 | [diff] [blame] | 17 | |
| 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | |
| 20 | import java.util.List; |
| 21 | |
| 22 | import org.onosproject.net.Device; |
| 23 | import org.onosproject.net.Device.Type; |
| 24 | import org.onosproject.net.DeviceId; |
| 25 | import org.onosproject.net.MastershipRole; |
| 26 | import org.onosproject.net.Port; |
| 27 | import org.onosproject.net.PortNumber; |
| 28 | import org.onosproject.net.device.DeviceListener; |
| 29 | import org.onosproject.net.device.DeviceService; |
| 30 | import org.onosproject.net.device.PortStatistics; |
| 31 | |
| 32 | import com.google.common.annotations.Beta; |
| 33 | |
| 34 | /** |
| 35 | * A DeviceService which forwards all its method calls to another DeviceService. |
| 36 | */ |
| 37 | @Beta |
| 38 | public abstract class ForwardingDeviceService implements DeviceService { |
| 39 | |
| 40 | private final DeviceService delegate; |
| 41 | |
| 42 | protected ForwardingDeviceService(DeviceService delegate) { |
| 43 | this.delegate = checkNotNull(delegate); |
| 44 | } |
| 45 | |
| 46 | protected final DeviceService delegate() { |
| 47 | return delegate; |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public void addListener(DeviceListener listener) { |
| 52 | delegate.addListener(listener); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public void removeListener(DeviceListener listener) { |
| 57 | delegate.removeListener(listener); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public int getDeviceCount() { |
| 62 | return delegate.getDeviceCount(); |
| 63 | } |
| 64 | |
| 65 | @Override |
mskala | 32000d3 | 2017-07-14 16:27:06 +0200 | [diff] [blame] | 66 | public int getAvailableDeviceCount() { |
| 67 | return delegate.getAvailableDeviceCount(); |
| 68 | } |
| 69 | |
| 70 | @Override |
HIGUCHI Yuta | 34a3f69 | 2016-01-09 21:08:57 -0800 | [diff] [blame] | 71 | public Iterable<Device> getDevices() { |
| 72 | return delegate.getDevices(); |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public Iterable<Device> getDevices(Type type) { |
| 77 | return delegate.getDevices(type); |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public Iterable<Device> getAvailableDevices() { |
| 82 | return delegate.getAvailableDevices(); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public Iterable<Device> getAvailableDevices(Type type) { |
| 87 | return delegate.getAvailableDevices(type); |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public Device getDevice(DeviceId deviceId) { |
| 92 | return delegate.getDevice(deviceId); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public MastershipRole getRole(DeviceId deviceId) { |
| 97 | return delegate.getRole(deviceId); |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public List<Port> getPorts(DeviceId deviceId) { |
| 102 | return delegate.getPorts(deviceId); |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public List<PortStatistics> getPortStatistics(DeviceId deviceId) { |
| 107 | return delegate.getPortStatistics(deviceId); |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { |
| 112 | return delegate.getPortDeltaStatistics(deviceId); |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public Port getPort(DeviceId deviceId, PortNumber portNumber) { |
| 117 | return delegate.getPort(deviceId, portNumber); |
| 118 | } |
| 119 | |
| 120 | @Override |
| 121 | public boolean isAvailable(DeviceId deviceId) { |
| 122 | return delegate.isAvailable(deviceId); |
| 123 | } |
| 124 | |
Yuta HIGUCHI | 24bc76b | 2017-03-01 21:09:59 -0800 | [diff] [blame] | 125 | @Override |
| 126 | public String localStatus(DeviceId deviceId) { |
| 127 | return delegate.localStatus(deviceId); |
| 128 | } |
| 129 | |
Ray Milkey | 054e23d | 2018-03-22 13:37:11 -0700 | [diff] [blame] | 130 | @Override |
| 131 | public long getLastUpdatedInstant(DeviceId deviceId) { |
| 132 | return delegate.getLastUpdatedInstant(deviceId); |
| 133 | } |
| 134 | |
HIGUCHI Yuta | 34a3f69 | 2016-01-09 21:08:57 -0800 | [diff] [blame] | 135 | } |