package org.opennms.core.utils;

public abstract class TimeSeries {
    public static final String TIMESERIES_GRAPHS_ENGINE_PROPERTY = "org.opennms.web.graphs.engine";
    public static final String TIMESERIES_STRATEGY_PROPERTY = "org.opennms.timeseries.strategy";
    public static final String DEFAULT_GRAPHS_ENGINE_TYPE = "auto";

    public static final String RRD_STRATEGY_CLASS_PROPERTY = "org.opennms.rrd.strategyClass";
    public static final String RRD_TIME_SERIES_STRATEGY_NAME = "rrd";
    public static final String DEFAULT_RRD_STRATEGY_CLASS = "org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy";

    private static final String NEWTS_TIME_SERIES_STRATEGY_NAME = "newts";

    private static final String EVALUETE_TIME_SERIES_STRATEGY_NAME = "evaluate";

    public static enum Strategy {
        RRD(RRD_TIME_SERIES_STRATEGY_NAME),
        NEWTS(NEWTS_TIME_SERIES_STRATEGY_NAME),
        EVALUATE(EVALUETE_TIME_SERIES_STRATEGY_NAME);

        private final String m_name;

        Strategy(String name) {
            m_name = name;
        }

        public String getName() {
            return m_name;
        }

        public String getDescr() {
            switch (m_name) {
                case RRD_TIME_SERIES_STRATEGY_NAME:
                    return "RRD (RRDTool or JRobin)";

                case NEWTS_TIME_SERIES_STRATEGY_NAME:
                    return "Newts";

                case EVALUETE_TIME_SERIES_STRATEGY_NAME:
                    return "Evaluate (Sizing mode, all data discarded)";
            }
	    return m_name;
        }
    }

    protected TimeSeries() {
        throw new UnsupportedOperationException();
    }

    public static Strategy getTimeseriesStrategy() {
        final String effectiveStrategyName = System.getProperty(TIMESERIES_STRATEGY_PROPERTY, RRD_TIME_SERIES_STRATEGY_NAME);
        for (Strategy strategy : Strategy.values()) {
            if (strategy.getName().equalsIgnoreCase(effectiveStrategyName)) {
                return strategy;
            }
        }
        throw new IllegalArgumentException("Unsupported time series strategy: " + effectiveStrategyName);
    }

    public static String getGraphEngine() {
        final String graphEngine = System.getProperty(TIMESERIES_GRAPHS_ENGINE_PROPERTY, DEFAULT_GRAPHS_ENGINE_TYPE);
        if (DEFAULT_GRAPHS_ENGINE_TYPE.equals(graphEngine)) {
            switch(TimeSeries.getTimeseriesStrategy()) {
            case RRD:
                return "png";
            default:
                return "backshift";
            }
        } else {
            return graphEngine;
        }
    }
}

@@ -828,32 +828,53 @@
 ES_STRATEGY_NAME
+, %22RRDTool or JRobin%22
 ),%0A        NEWTS
@@ -905,16 +905,25 @@
 EGY_NAME
+, %22Newts%22
 ),%0A     
@@ -972,49 +972,239 @@
 NAME
-);%0A%0A        private final String m_name;%0A
+, %22Evaluate (Sizing mode, all data discarded)%22);%0A%0A        private final String m_name;%0A        private final String m_descr;%0A%0A        Strategy(String name, String descr) %7B%0A        %09m_name = name;%0A        %09m_descr = descr;%0A        %7D
 %0A   
@@ -1244,29 +1244,32 @@
         
-m_
+this(
 name
- =
+,
  name
+)
 ;%0A      
@@ -1392,390 +1392,23 @@
     
-    switch (m_name) %7B%0A                case RRD_TIME_SERIES_STRATEGY_NAME:%0A                    return %22RRD (RRDTool or JRobin)%22;%0A%0A                case NEWTS_TIME_SERIES_STRATEGY_NAME:%0A                    return %22Newts%22;%0A%0A                case EVALUETE_TIME_SERIES_STRATEGY_NAME:%0A                    return %22Evaluate (Sizing mode, all data discarded)%22;%0A            %7D%0A%09    return m_name
+%09return m_descr
 ;%0A  

Refactor to eliminate case statement.