[ONOS-4513] Move utilities not specific to optical out of optical package.

Change-Id: Ib4d33008c61f17b8ff220142a0d15db31e5fcfb9
diff --git a/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java b/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
index 23f3c57..c5b1ff0 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
@@ -32,7 +32,7 @@
 import org.onosproject.net.optical.device.port.OmsPortMapper;
 import org.onosproject.net.optical.device.port.OtuPortMapper;
 import org.onosproject.net.optical.device.port.PortMapper;
-import org.onosproject.net.optical.utils.ForwardingDevice;
+import org.onosproject.net.utils.ForwardingDevice;
 import org.slf4j.Logger;
 
 import com.google.common.annotations.Beta;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java b/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
index c898f70..da4da82 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
@@ -25,7 +25,7 @@
 import org.onosproject.net.device.DeviceListener;
 import org.onosproject.net.device.DeviceService;
 import org.onosproject.net.optical.OpticalDevice;
-import org.onosproject.net.optical.utils.ForwardingDeviceService;
+import org.onosproject.net.utils.ForwardingDeviceService;
 import org.slf4j.Logger;
 
 import com.google.common.annotations.Beta;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
index 019f8c9..593b021 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
@@ -20,7 +20,7 @@
 import org.onosproject.net.OduSignalType;
 import org.onosproject.net.Port;
 import org.onosproject.net.optical.OchPort;
-import org.onosproject.net.optical.utils.ForwardingPort;
+import org.onosproject.net.utils.ForwardingPort;
 
 import com.google.common.annotations.Beta;
 
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
index f98becd..78a4266 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
@@ -22,7 +22,7 @@
 import org.onosproject.net.CltSignalType;
 import org.onosproject.net.Port;
 import org.onosproject.net.optical.OduCltPort;
-import org.onosproject.net.optical.utils.ForwardingPort;
+import org.onosproject.net.utils.ForwardingPort;
 
 import com.google.common.annotations.Beta;
 
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
index 4c1c7e3..eb2c426 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
@@ -22,7 +22,7 @@
 import org.onlab.util.Frequency;
 import org.onosproject.net.Port;
 import org.onosproject.net.optical.OmsPort;
-import org.onosproject.net.optical.utils.ForwardingPort;
+import org.onosproject.net.utils.ForwardingPort;
 
 import com.google.common.annotations.Beta;
 
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
index 4a5a79b..2c038c8 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
@@ -22,7 +22,7 @@
 import org.onosproject.net.OtuSignalType;
 import org.onosproject.net.Port;
 import org.onosproject.net.optical.OtuPort;
-import org.onosproject.net.optical.utils.ForwardingPort;
+import org.onosproject.net.utils.ForwardingPort;
 
 import com.google.common.annotations.Beta;
 
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDevice.java b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDevice.java
deleted file mode 100644
index 389f42b..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDevice.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical.utils;
-
-import org.onlab.packet.ChassisId;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.driver.Behaviour;
-import org.onosproject.net.provider.ProviderId;
-
-import com.google.common.annotations.Beta;
-
-/**
- * A Device which forwards all its method calls to another Device.
- */
-@Beta
-public interface ForwardingDevice extends Device {
-
-    Device delegate();
-
-    @Override
-    default Annotations annotations() {
-        return delegate().annotations();
-    }
-
-    @Override
-    default ProviderId providerId() {
-        return delegate().providerId();
-    }
-
-    @Override
-    default <B extends Behaviour> B as(Class<B> projectionClass) {
-        return delegate().as(projectionClass);
-    }
-
-    @Override
-    default DeviceId id() {
-        return delegate().id();
-    }
-
-    @Override
-    default Type type() {
-        return delegate().type();
-    }
-
-    @Override
-    default <B extends Behaviour> boolean is(Class<B> projectionClass) {
-        return delegate().is(projectionClass);
-    }
-
-    @Override
-    default String manufacturer() {
-        return delegate().manufacturer();
-    }
-
-    @Override
-    default String hwVersion() {
-        return delegate().hwVersion();
-    }
-
-    @Override
-    default String swVersion() {
-        return delegate().swVersion();
-    }
-
-    @Override
-    default String serialNumber() {
-        return delegate().serialNumber();
-    }
-
-    @Override
-    default ChassisId chassisId() {
-        return delegate().chassisId();
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDeviceService.java b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDeviceService.java
deleted file mode 100644
index 7bcec14..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDeviceService.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical.utils;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.Device.Type;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.PortStatistics;
-
-import com.google.common.annotations.Beta;
-
-/**
- * A DeviceService which forwards all its method calls to another DeviceService.
- */
-@Beta
-public abstract class ForwardingDeviceService implements DeviceService {
-
-    private final DeviceService delegate;
-
-    protected ForwardingDeviceService(DeviceService delegate) {
-        this.delegate = checkNotNull(delegate);
-    }
-
-    protected final DeviceService delegate() {
-        return delegate;
-    }
-
-    @Override
-    public void addListener(DeviceListener listener) {
-        delegate.addListener(listener);
-    }
-
-    @Override
-    public void removeListener(DeviceListener listener) {
-        delegate.removeListener(listener);
-    }
-
-    @Override
-    public int getDeviceCount() {
-        return delegate.getDeviceCount();
-    }
-
-    @Override
-    public Iterable<Device> getDevices() {
-        return delegate.getDevices();
-    }
-
-    @Override
-    public Iterable<Device> getDevices(Type type) {
-        return delegate.getDevices(type);
-    }
-
-    @Override
-    public Iterable<Device> getAvailableDevices() {
-        return delegate.getAvailableDevices();
-    }
-
-    @Override
-    public Iterable<Device> getAvailableDevices(Type type) {
-        return delegate.getAvailableDevices(type);
-    }
-
-    @Override
-    public Device getDevice(DeviceId deviceId) {
-        return delegate.getDevice(deviceId);
-    }
-
-    @Override
-    public MastershipRole getRole(DeviceId deviceId) {
-        return delegate.getRole(deviceId);
-    }
-
-    @Override
-    public List<Port> getPorts(DeviceId deviceId) {
-        return delegate.getPorts(deviceId);
-    }
-
-    @Override
-    public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
-        return delegate.getPortStatistics(deviceId);
-    }
-
-    @Override
-    public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
-        return delegate.getPortDeltaStatistics(deviceId);
-    }
-
-    @Override
-    public Port getPort(DeviceId deviceId, PortNumber portNumber) {
-        return delegate.getPort(deviceId, portNumber);
-    }
-
-    @Override
-    public boolean isAvailable(DeviceId deviceId) {
-        return delegate.isAvailable(deviceId);
-    }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingPort.java b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingPort.java
deleted file mode 100644
index f241625..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingPort.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.optical.utils;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.Element;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * A Port which forwards all its method calls to another Port.
- */
-@Beta
-public abstract class ForwardingPort implements Port {
-
-    private final Port delegate;
-
-    protected ForwardingPort(Port delegate) {
-        this.delegate = checkNotNull(delegate);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(element().id(),
-                            number(),
-                            isEnabled(),
-                            type(),
-                            portSpeed(),
-                            annotations());
-    }
-
-    /**
-     * Returns {@link EqualsBuilder} comparing all Port attributes
-     * including annotations.
-     * <p>
-     * To add extra fields to equality,
-     * call {@code super.toEqualsBuilder(..)} and append fields.
-     * To remove field from comparison, override this method
-     * or manually implement equals().
-     */
-    protected EqualsBuilder toEqualsBuilder(Port that) {
-        if (that == null) {
-            return new EqualsBuilder().appendSuper(false);
-        }
-        return new EqualsBuilder()
-                .append(this.element().id(), that.element().id())
-                .append(this.number(), that.number())
-                .append(this.isEnabled(), that.isEnabled())
-                .append(this.type(), that.type())
-                .append(this.portSpeed(), that.portSpeed())
-                .append(this.annotations(), that.annotations());
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-
-        if (obj != null && getClass() == obj.getClass()) {
-            final ForwardingPort that = (ForwardingPort) obj;
-            return toEqualsBuilder(that)
-                    .isEquals();
-        }
-        return false;
-    }
-
-    /**
-     * Returns {@link ToStringHelper} with Port attributes excluding annotations.
-     *
-     * @return {@link ToStringHelper}
-     */
-    protected ToStringHelper toStringHelper() {
-        return MoreObjects.toStringHelper(this)
-                .add("element", element().id())
-                .add("number", number())
-                .add("isEnabled", isEnabled())
-                .add("type", type())
-                .add("portSpeed", portSpeed());
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper()
-                .toString();
-    }
-
-    @Override
-    public Annotations annotations() {
-        return delegate.annotations();
-    }
-
-    @Override
-    public Element element() {
-        return delegate.element();
-    }
-
-    @Override
-    public PortNumber number() {
-        return delegate.number();
-    }
-
-    @Override
-    public boolean isEnabled() {
-        return delegate.isEnabled();
-    }
-
-    @Override
-    public Port.Type type() {
-        return delegate.type();
-    }
-
-    @Override
-    public long portSpeed() {
-        return delegate.portSpeed();
-    }
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/utils/package-info.java
deleted file mode 100644
index ae8d0b5..0000000
--- a/core/api/src/main/java/org/onosproject/net/optical/utils/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Utility classes.
- */
-package org.onosproject.net.optical.utils;