I got a sample code based on switch statement. I want some how add it in arrayList or HashMap. Also, what do you think which option would be good to use and why?
public static final IFeatureExtraction create(final int piFeatureExtractionMethod, IPreprocessing poPreprocessing)
throws FeatureExtractionException
{
IFeatureExtraction oFeatureExtraction = null;
switch(piFeatureExtractionMethod)
{
case MARF.LPC:
oFeatureExtraction = new LPC(poPreprocessing);
break;
case MARF.FFT:
oFeatureExtraction = new FFT(poPreprocessing);
break;
case MARF.F0:
oFeatureExtraction = new F0(poPreprocessing);
break;
case MARF.SEGMENTATION:
oFeatureExtraction = new Segmentation(poPreprocessing);
break;
case MARF.CEPSTRAL:
oFeatureExtraction = new Cepstral(poPreprocessing);
break;
case MARF.RANDOM_FEATURE_EXTRACTION:
oFeatureExtraction = new RandomFeatureExtraction(poPreprocessing);
break;
case MARF.MIN_MAX_AMPLITUDES:
oFeatureExtraction = new MinMaxAmplitudes(poPreprocessing);
break;
case MARF.FEATURE_EXTRACTION_PLUGIN:
{
try
{
oFeatureExtraction = (IFeatureExtraction)MARF.getFeatureExtractionPluginClass().newInstance();
oFeatureExtraction.setPreprocessing(poPreprocessing);
}
catch(Exception e)
{
throw new FeatureExtractionException(e.getMessage(), e);
}
break;
}
case MARF.FEATURE_EXTRACTION_AGGREGATOR:
{
oFeatureExtraction = new FeatureExtractionAggregator(poPreprocessing);
break;
}
default:
{
throw new FeatureExtractionException
(
"Unknown feature extraction method: " + piFeatureExtractionMethod
);
}
}
return oFeatureExtraction;
}
Do you think can any other pattern be applied to it. Mention the pattern name you recommend. Will appreciate extra implementation ideas.