/*
 * Copyright 2014-2015 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.resource;

import java.util.Objects;

/**
 * Representation of bandwidth resource in bps.
 */
public final class BandwidthResource extends LinkResource {

    private final double bandwidth;

    /**
     * Creates a new instance with given bandwidth.
     *
     * @param bandwidth bandwidth value to be assigned
     */
    private BandwidthResource(double bandwidth) {
        this.bandwidth = bandwidth;
    }

    // Constructor for serialization
    private BandwidthResource() {
        this.bandwidth = 0;
    }

    /**
     * Creates a new instance with given bandwidth in bps.
     *
     * @param bandwidth bandwidth value to be assigned
     * @return {@link BandwidthResource} instance with given bandwidth
     */
    @Deprecated
    public static BandwidthResource valueOf(double bandwidth) {
        return bps(bandwidth);
    }

    /**
     * Creates a new instance with given bandwidth in bps.
     *
     * @param bandwidth bandwidth value to be assigned
     * @return {@link BandwidthResource} instance with given bandwidth
     */
    public static BandwidthResource bps(double bandwidth) {
        return new BandwidthResource(bandwidth);
    }

    /**
     * Creates a new instance with given bandwidth in Kbps.
     *
     * @param bandwidth bandwidth value to be assigned
     * @return {@link BandwidthResource} instance with given bandwidth
     */
    public static BandwidthResource kbps(double bandwidth) {
        return new BandwidthResource(bandwidth * 1_000L);
    }

    /**
     * Creates a new instance with given bandwidth in Mbps.
     *
     * @param bandwidth bandwidth value to be assigned
     * @return {@link BandwidthResource} instance with given bandwidth
     */
    public static BandwidthResource mbps(double bandwidth) {
        return new BandwidthResource(bandwidth * 1_000_000L);
    }

    /**
     * Creates a new instance with given bandwidth in Gbps.
     *
     * @param bandwidth bandwidth value to be assigned
     * @return {@link BandwidthResource} instance with given bandwidth
     */
    public static BandwidthResource gbps(double bandwidth) {
        return new BandwidthResource(bandwidth * 1_000_000_000L);
    }

    /**
     * Returns bandwidth as a double value.
     *
     * @return bandwidth as a double value
     */
    public double toDouble() {
        return bandwidth;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof BandwidthResource) {
            BandwidthResource that = (BandwidthResource) obj;
            return Objects.equals(this.bandwidth, that.bandwidth);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(this.bandwidth);
    }

    @Override
    public String toString() {
        return String.valueOf(this.bandwidth);
    }
}

@@ -1568,32 +1568,26 @@
   * @param b
-andwidth
+ps
  bandwidth v
@@ -1729,32 +1729,26 @@
 bps(double b
-andwidth
+ps
 ) %7B%0A        
@@ -1777,24 +1777,18 @@
 source(b
-andwidth
+ps
 );%0A    %7D
@@ -1874,33 +1874,28 @@
    * @param 
-bandwidth
+kbps
  bandwidth v
@@ -2037,33 +2037,28 @@
 kbps(double 
-bandwidth
+kbps
 ) %7B%0A        
@@ -2082,33 +2082,28 @@
 dthResource(
-bandwidth
+kbps
  * 1_000L);%0A
@@ -2194,33 +2194,28 @@
    * @param 
-bandwidth
+mbps
  bandwidth v
@@ -2357,33 +2357,28 @@
 mbps(double 
-bandwidth
+mbps
 ) %7B%0A        
@@ -2402,33 +2402,28 @@
 dthResource(
-bandwidth
+mbps
  * 1_000_000
@@ -2518,33 +2518,28 @@
    * @param 
-bandwidth
+gbps
  bandwidth v
@@ -2681,33 +2681,28 @@
 gbps(double 
-bandwidth
+gbps
 ) %7B%0A        
@@ -2730,25 +2730,20 @@
 esource(
-bandwidth
+gbps
  * 1_000

Rename arguments to make its meaning clear