// Path: src/main/java/com/zavakid/mushroom/Metric.java
// public abstract class Metric {
// 
//     public static final String NO_DESCRIPTION = "<<no description>>";
//     private final String       name;
//     private final String       description;
// 
//     /**
//      * Construct the metric with name only
//      * 
//      * @param name of the metric
//      */
//     public Metric(String name){
//         this.name = name;
//         this.description = NO_DESCRIPTION;
//     }
// 
//     /**
//      * Construct the metric with a name and a description
//      * 
//      * @param name of the metric
//      * @param desc description of the metric
//      */
//     public Metric(String name, String desc){
//         this.name = name;
//         this.description = desc;
//     }
// 
//     /**
//      * Get the name of the metric
//      * 
//      * @return the name
//      */
//     public String name() {
//         return name;
//     }
// 
//     /**
//      * Get the description of the metric
//      * 
//      * @return the description
//      */
//     public String description() {
//         return description;
//     }
// 
//     /**
//      * Get the value of the metric
//      * 
//      * @return the value of the metric
//      */
//     public abstract Number value();
// 
//     /**
//      * Accept a visitor interface
//      * 
//      * @param visitor of the metric
//      */
//     public abstract void visit(MetricsVisitor visitor);
// 
//     // Mostly for testing
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == null) {
//             return false;
//         }
//         if (getClass() != obj.getClass()) {
//             return false;
//         }
//         final Metric other = (Metric) obj;
//         if (!this.name.equals(other.name())) {
//             return false;
//         }
//         if (!this.description.equals(other.description())) {
//             return false;
//         }
//         if (!value().equals(other.value())) {
//             return false;
//         }
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return name.hashCode();
//     }
// 
//     @Override
//     public String toString() {
//         return "Metric{" + "name='" + name + "' description='" + description + "' value=" + value() + '}';
//     }
// }


import com.zavakid.mushroom.Metric;
/**
   Copyright [2013] [Mushroom]

   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.
 */
/**
 Notice : this source is extracted from Hadoop metric2 package
 and some source code may changed by zavakid
 */
package com.zavakid.mushroom.lib;


/**
 * Factory class for mutable metrics
 * 
 * @author Hadoop metric2 package's authors
 * @since 0.1
 */
public class MetricMutableFactory {

    static final String DEFAULT_SAMPLE_NAME = "ops";
    static final String DEFAULT_VALUE_NAME  = "time";

    /**
     * Create a new mutable metric by name Usually overridden by app specific factory
     * 
     * @param name of the metric
     * @return a new metric object
     */
    public MetricMutable newMetric(String name) {
        return null;
    }

    /**
     * Create a mutable integer counter
     * 
     * @param name of the metric
     * @param description of the metric
     * @param initValue of the metric
     * @return a new metric object
     */
    public MetricMutableCounterInt newCounter(String name, String description, int initValue) {
        return new MetricMutableCounterInt(name, description, initValue);
    }

    /**
     * Create a mutable integer counter with name only. Usually gets overridden.
     * 
     * @param name of the metric
     * @return a new metric object
     */
    public MetricMutableCounterInt newCounterInt(String name) {
        return new MetricMutableCounterInt(name, Metric.NO_DESCRIPTION, 0);
    }

    /**
     * Create a mutable long integer counter
     * 
     * @param name of the metric
     * @param description of the metric
     * @param initValue of the metric
     * @return a new metric object
     */
    public MetricMutableCounterLong newCounter(String name, String description, long initValue) {
        return new MetricMutableCounterLong(name, description, initValue);
    }

    /**
     * Create a mutable long integer counter with a name Usually gets overridden.
     * 
     * @param name of the metric
     * @return a new metric object
     */
    public MetricMutableCounterLong newCounterLong(String name) {
// Path: src/main/java/com/zavakid/mushroom/Metric.java
// public abstract class Metric {
// 
//     public static final String NO_DESCRIPTION = "<<no description>>";
//     private final String       name;
//     private final String       description;
// 
//     /**
//      * Construct the metric with name only
//      * 
//      * @param name of the metric
//      */
//     public Metric(String name){
//         this.name = name;
//         this.description = NO_DESCRIPTION;
//     }
// 
//     /**
//      * Construct the metric with a name and a description
//      * 
//      * @param name of the metric
//      * @param desc description of the metric
//      */
//     public Metric(String name, String desc){
//         this.name = name;
//         this.description = desc;
//     }
// 
//     /**
//      * Get the name of the metric
//      * 
//      * @return the name
//      */
//     public String name() {
//         return name;
//     }
// 
//     /**
//      * Get the description of the metric
//      * 
//      * @return the description
//      */
//     public String description() {
//         return description;
//     }
// 
//     /**
//      * Get the value of the metric
//      * 
//      * @return the value of the metric
//      */
//     public abstract Number value();
// 
//     /**
//      * Accept a visitor interface
//      * 
//      * @param visitor of the metric
//      */
//     public abstract void visit(MetricsVisitor visitor);
// 
//     // Mostly for testing
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == null) {
//             return false;
//         }
//         if (getClass() != obj.getClass()) {
//             return false;
//         }
//         final Metric other = (Metric) obj;
//         if (!this.name.equals(other.name())) {
//             return false;
//         }
//         if (!this.description.equals(other.description())) {
//             return false;
//         }
//         if (!value().equals(other.value())) {
//             return false;
//         }
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return name.hashCode();
//     }
// 
//     @Override
//     public String toString() {
//         return "Metric{" + "name='" + name + "' description='" + description + "' value=" + value() + '}';
//     }
// }


// Path: src/main/java/com/zavakid/mushroom/lib/MetricMutableFactory.java
import com.zavakid.mushroom.Metric;

/**
   Copyright [2013] [Mushroom]

   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.
 */
/**
 Notice : this source is extracted from Hadoop metric2 package
 and some source code may changed by zavakid
 */
package com.zavakid.mushroom.lib;


/**
 * Factory class for mutable metrics
 * 
 * @author Hadoop metric2 package's authors
 * @since 0.1
 */
public class MetricMutableFactory {

    static final String DEFAULT_SAMPLE_NAME = "ops";
    static final String DEFAULT_VALUE_NAME  = "time";

    /**
     * Create a new mutable metric by name Usually overridden by app specific factory
     * 
     * @param name of the metric
     * @return a new metric object
     */
    public MetricMutable newMetric(String name) {
        return null;
    }

    /**
     * Create a mutable integer counter
     * 
     * @param name of the metric
     * @param description of the metric
     * @param initValue of the metric
     * @return a new metric object
     */
    public MetricMutableCounterInt newCounter(String name, String description, int initValue) {
        return new MetricMutableCounterInt(name, description, initValue);
    }

    /**
     * Create a mutable integer counter with name only. Usually gets overridden.
     * 
     * @param name of the metric
     * @return a new metric object
     */
    public MetricMutableCounterInt newCounterInt(String name) {
        return new MetricMutableCounterInt(name, Metric.NO_DESCRIPTION, 0);
    }

    /**
     * Create a mutable long integer counter
     * 
     * @param name of the metric
     * @param description of the metric
     * @param initValue of the metric
     * @return a new metric object
     */
    public MetricMutableCounterLong newCounter(String name, String description, long initValue) {
        return new MetricMutableCounterLong(name, description, initValue);
    }

    /**
     * Create a mutable long integer counter with a name Usually gets overridden.
     * 
     * @param name of the metric
     * @return a new metric object
     */
    public MetricMutableCounterLong newCounterLong(String name) {
        return new MetricMutableCounterLong(name, Metric.NO_DESCRIPTION, 0L);