Search in sources :

Example 1 with Parameterization

use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization in project elki by elki-project.

the class ObjectListParameter method instantiateClasses.

@Override
public List<C> instantiateClasses(Parameterization config) {
    if (instances == null) {
        // instantiateClasses will descend itself.
        instances = super.instantiateClasses(config);
    } else {
        Parameterization cfg = null;
        for (int i = 0; i < instances.size(); i++) {
            if (instances.get(i) == null) {
                Class<? extends C> cls = getValue().get(i);
                try {
                    // Descend at most once, and only when needed
                    cfg = (cfg == null) ? config.descend(this) : null;
                    C instance = ClassGenericsUtil.tryInstantiate(restrictionClass, cls, cfg);
                    instances.set(i, instance);
                } catch (Exception e) {
                    config.reportError(new WrongParameterValueException(this, cls.getName(), e.getMessage(), e));
                }
            }
        }
    }
    return new ArrayList<>(instances);
}
Also used : WrongParameterValueException(de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException) ArrayList(java.util.ArrayList) Parameterization(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization) UnspecifiedParameterException(de.lmu.ifi.dbs.elki.utilities.optionhandling.UnspecifiedParameterException) WrongParameterValueException(de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException) ParameterException(de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException)

Aggregations

ParameterException (de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException)1 UnspecifiedParameterException (de.lmu.ifi.dbs.elki.utilities.optionhandling.UnspecifiedParameterException)1 WrongParameterValueException (de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException)1 Parameterization (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization)1 ArrayList (java.util.ArrayList)1