diff options
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters')
23 files changed, 90 insertions, 134 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/AbstractParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/AbstractParameter.java index ce4b094d..8e1b48c3 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/AbstractParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/AbstractParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -334,7 +334,7 @@ public abstract class AbstractParameter<T> implements Parameter<T> { @Override public void addConstraint(ParameterConstraint<? super T> constraint) { if (constraints == null) { - this.constraints = new ArrayList<ParameterConstraint<? super T>>(1); + this.constraints = new ArrayList<>(1); } constraints.add(constraint); } @@ -346,7 +346,7 @@ public abstract class AbstractParameter<T> implements Parameter<T> { */ public void addConstraints(Collection<? extends ParameterConstraint<? super T>> cs) { if (constraints == null) { - this.constraints = new ArrayList<ParameterConstraint<? super T>>(cs.size()); + this.constraints = new ArrayList<>(cs.size()); } constraints.addAll(cs); } diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassListParameter.java index f87e3973..35cd0573 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -48,11 +48,6 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameteriz // TODO: Add missing constructors. (ObjectListParameter also!) public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { /** - * Class loader - */ - protected static final ClassLoader loader = ClassLoader.getSystemClassLoader(); - - /** * The restriction class for the list of class names. */ protected Class<C> restrictionClass; @@ -88,12 +83,12 @@ public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { public String getValueAsString() { StringBuilder buf = new StringBuilder(); final String defPackage = restrictionClass.getPackage().getName() + "."; - for(Class<? extends C> c : getValue()) { - if(buf.length() > 0) { + for (Class<? extends C> c : getValue()) { + if (buf.length() > 0) { buf.append(LIST_SEP); } String name = c.getName(); - if(name.startsWith(defPackage)) { + if (name.startsWith(defPackage)) { name = name.substring(defPackage.length()); } buf.append(name); @@ -107,57 +102,41 @@ public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { try { List<?> l = List.class.cast(obj); // do extra validation: - for(Object o : l) { - if(!(o instanceof Class)) { + for (Object o : l) { + if (!(o instanceof Class)) { throw new WrongParameterValueException("Wrong parameter format for parameter \"" + getName() + "\". Given list contains objects of different type!"); } } // TODO: can we use reflection to get extra checks? // TODO: Should we copy the list? return (List<Class<? extends C>>) l; - } - catch(ClassCastException e) { + } catch (ClassCastException e) { // continue with others } // Did we get a single class? try { - if(restrictionClass.isAssignableFrom((Class<?>) obj)) { - List<Class<? extends C>> clss = new ArrayList<Class<? extends C>>(1); + if (restrictionClass.isAssignableFrom((Class<?>) obj)) { + List<Class<? extends C>> clss = new ArrayList<>(1); clss.add((Class<? extends C>) obj); return clss; } - } - catch(ClassCastException e) { + } catch (ClassCastException e) { // continue with others } - if(obj instanceof String) { + if (obj instanceof String) { String[] classes = SPLIT.split((String) obj); // TODO: allow empty lists (and list constraints) to enforce length? - if(classes.length == 0) { + if (classes.length == 0) { throw new WrongParameterValueException("Wrong parameter format! Given list of classes for parameter \"" + getName() + "\" is either empty or has the wrong format!"); } - List<Class<? extends C>> cls = new ArrayList<Class<? extends C>>(classes.length); - for(String cl : classes) { - try { - Class<?> c; - try { - c = loader.loadClass(cl); - } - catch(ClassNotFoundException e) { - // try in package of restriction class - c = loader.loadClass(restrictionClass.getPackage().getName() + "." + cl); - } - // Redundant check, also in validate(), but not expensive. - if(!restrictionClass.isAssignableFrom(c)) { - throw new WrongParameterValueException(this, cl, "Class \"" + cl + "\" does not extend/implement restriction class " + restrictionClass + ".\n"); - } - else { - cls.add((Class<? extends C>) c); - } - } - catch(ClassNotFoundException e) { - throw new WrongParameterValueException(this, cl, "Class \"" + cl + "\" not found.\n", e); + List<Class<? extends C>> cls = new ArrayList<>(classes.length); + for (String cl : classes) { + Class<? extends C> clz = InspectionUtil.findImplementation(restrictionClass, cl); + if (clz != null) { + cls.add(clz); + } else { + throw new WrongParameterValueException(this, (String) obj, "Class '" + cl + "' not found for given value. Must be a subclass / implementation of " + restrictionClass.getName()); } } return cls; @@ -168,8 +147,8 @@ public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { @Override protected boolean validate(List<Class<? extends C>> obj) throws ParameterException { - for(Class<? extends C> cls : obj) { - if(!restrictionClass.isAssignableFrom(cls)) { + for (Class<? extends C> cls : obj) { + if (!restrictionClass.isAssignableFrom(cls)) { throw new WrongParameterValueException(this, cls.getName(), "Class \"" + cls.getName() + "\" does not extend/implement restriction class " + restrictionClass + ".\n"); } } @@ -217,20 +196,19 @@ public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { */ public List<C> instantiateClasses(Parameterization config) { config = config.descend(this); - List<C> instances = new ArrayList<C>(); - if(getValue() == null) { + List<C> instances = new ArrayList<>(); + if (getValue() == null) { config.reportError(new UnusedParameterException("Value of parameter " + getName() + " has not been specified.")); return instances; // empty list. } - for(Class<? extends C> cls : getValue()) { + for (Class<? extends C> cls : getValue()) { // NOTE: There is a duplication of this code in ObjectListParameter - keep // in sync! try { C instance = ClassGenericsUtil.tryInstantiate(restrictionClass, cls, config); instances.add(instance); - } - catch(Exception e) { + } catch (Exception e) { config.reportError(new WrongParameterValueException(this, cls.getName(), e)); } } @@ -247,26 +225,24 @@ public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { public String restrictionString() { String prefix = restrictionClass.getPackage().getName() + "."; StringBuilder info = new StringBuilder(); - if(restrictionClass.isInterface()) { + if (restrictionClass.isInterface()) { info.append("Implementing "); - } - else { + } else { info.append("Extending "); } info.append(restrictionClass.getName()); info.append(FormatUtil.NEWLINE); List<Class<?>> known = getKnownImplementations(); - if(!known.isEmpty()) { + if (!known.isEmpty()) { info.append("Known classes (default package " + prefix + "):"); info.append(FormatUtil.NEWLINE); - for(Class<?> c : known) { + for (Class<?> c : known) { info.append("->" + FormatUtil.NONBREAKING_SPACE); String name = c.getName(); - if(name.startsWith(prefix)) { + if (name.startsWith(prefix)) { info.append(name.substring(prefix.length())); - } - else { + } else { info.append(name); } info.append(FormatUtil.NEWLINE); @@ -292,9 +268,9 @@ public class ClassListParameter<C> extends ListParameter<Class<? extends C>> { */ @Override public String getValuesDescription() { - if(restrictionClass != null && restrictionClass != Object.class) { + if (restrictionClass != null && restrictionClass != Object.class) { return restrictionString(); } return ""; } -}
\ No newline at end of file +} diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassParameter.java index 6d63f9b5..a0669fca 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -51,16 +51,6 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameteriz // TODO: turn restrictionClass into a constraint? public class ClassParameter<C> extends AbstractParameter<Class<? extends C>> { /** - * Class loader. - */ - protected static final ClassLoader loader = ClassLoader.getSystemClassLoader(); - - /** - * Factory class postfix. - */ - public static final String FACTORY_POSTFIX = "$Factory"; - - /** * The restriction class for this class parameter. */ protected Class<C> restrictionClass; @@ -132,29 +122,9 @@ public class ClassParameter<C> extends AbstractParameter<Class<? extends C>> { return (Class<? extends C>) obj; } if (obj instanceof String) { - String value = (String) obj; - try { - // Try exact class factory first. - try { - return (Class<? extends C>) loader.loadClass(value + FACTORY_POSTFIX); - } catch (ClassNotFoundException e) { - // Ignore, retry - } - try { - return (Class<? extends C>) loader.loadClass(value); - } catch (ClassNotFoundException e) { - // Ignore, retry - } - // Try factory for guessed name next - try { - return (Class<? extends C>) loader.loadClass(restrictionClass.getPackage().getName() + "." + value + FACTORY_POSTFIX); - } catch (ClassNotFoundException e) { - // Ignore, retry - } - // Last try: guessed name prefix only - return (Class<? extends C>) loader.loadClass(restrictionClass.getPackage().getName() + "." + value); - } catch (ClassNotFoundException e) { - throw new WrongParameterValueException(this, value, "Given class \"" + value + "\" not found.", e); + Class<? extends C> clz = InspectionUtil.findImplementation(restrictionClass, (String) obj); + if (clz != null) { + return clz; } } throw new WrongParameterValueException(this, obj.toString(), "Class not found for given value. Must be a subclass / implementation of " + restrictionClass.getName()); @@ -330,9 +300,9 @@ public class ClassParameter<C> extends AbstractParameter<Class<? extends C>> { */ public static String canonicalClassName(Class<?> c, Class<?> parent) { if (parent == null) { - return canonicalClassName(c, null, FACTORY_POSTFIX); + return canonicalClassName(c, null, InspectionUtil.FACTORY_POSTFIX); } - return canonicalClassName(c, parent.getPackage(), FACTORY_POSTFIX); + return canonicalClassName(c, parent.getPackage(), InspectionUtil.FACTORY_POSTFIX); } @Override diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DistanceParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DistanceParameter.java index f9943610..e97b6d0e 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DistanceParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DistanceParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleListParameter.java index 885a3bfc..89cfc345 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -81,7 +81,7 @@ public class DoubleListParameter extends ListParameter<Double> { } if(obj instanceof String) { String[] values = SPLIT.split((String) obj); - ArrayList<Double> doubleValue = new ArrayList<Double>(values.length); + ArrayList<Double> doubleValue = new ArrayList<>(values.length); for(String val : values) { doubleValue.add(Double.valueOf(val)); } diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleParameter.java index 4aee3511..632e1f8c 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/DoubleParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java index c2e1c733..4d05753c 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java @@ -111,14 +111,16 @@ public class EnumParameter<E extends Enum<E>> extends AbstractParameter<E> { @Override
protected E parseValue(Object obj) throws ParameterException {
- if(obj == null) {
+ if (obj == null) {
throw new UnspecifiedParameterException(this);
}
- if(obj instanceof String) {
+ if (enumClass.isInstance(obj)) {
+ return enumClass.cast(obj);
+ }
+ if (obj instanceof String) {
try {
return Enum.valueOf(enumClass, (String) obj);
- }
- catch(IllegalArgumentException ex) {
+ } catch (IllegalArgumentException ex) {
throw new WrongParameterValueException("Enum parameter " + getName() + " is invalid (must be one of [" + joinEnumNames(", ") + "].");
}
}
@@ -138,8 +140,8 @@ public class EnumParameter<E extends Enum<E>> extends AbstractParameter<E> { public Collection<String> getPossibleValues() {
// Convert to string array
final E[] enums = enumClass.getEnumConstants();
- ArrayList<String> values = new ArrayList<String>(enums.length);
- for(E t : enums) {
+ ArrayList<String> values = new ArrayList<>(enums.length);
+ for (E t : enums) {
values.add(t.name());
}
return values;
@@ -155,8 +157,8 @@ public class EnumParameter<E extends Enum<E>> extends AbstractParameter<E> { private String joinEnumNames(String separator) {
E[] enumTypes = enumClass.getEnumConstants();
StringBuilder sb = new StringBuilder();
- for(int i = 0; i < enumTypes.length; ++i) {
- if(i > 0) {
+ for (int i = 0; i < enumTypes.length; ++i) {
+ if (i > 0) {
sb.append(separator);
}
sb.append(enumTypes[i].name());
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileListParameter.java index 203712aa..eb638298 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -108,7 +108,7 @@ public class FileListParameter extends ListParameter<File> { } if(obj instanceof String) { String[] values = SPLIT.split((String) obj); - ArrayList<File> fileValue = new ArrayList<File>(values.length); + ArrayList<File> fileValue = new ArrayList<>(values.length); for(String val : values) { fileValue.add(new File(val)); } diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileParameter.java index 2cc5ab37..ea3fa454 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/FileParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -137,4 +137,13 @@ public class FileParameter extends AbstractParameter<File> { public String getSyntax() { return "<file>"; } + + /** + * Get the file type (input / output) + * + * @return file type + */ + public FileType getFileType() { + return fileType; + } } diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Flag.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Flag.java index 90230077..7587d2a5 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Flag.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Flag.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntListParameter.java index f61f8842..93012955 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -90,7 +90,7 @@ public class IntListParameter extends ListParameter<Integer> { } if(obj instanceof String) { String[] values = SPLIT.split((String) obj); - ArrayList<Integer> intValue = new ArrayList<Integer>(values.length); + ArrayList<Integer> intValue = new ArrayList<>(values.length); for(String val : values) { intValue.add(Integer.valueOf(val)); } diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntParameter.java index 22823e16..30457330 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/IntParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java index e71a744e..119fb121 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java index ac8bd62c..f5d441b5 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/NumberParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/NumberParameter.java index 8928c292..a4448d30 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/NumberParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/NumberParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectListParameter.java index 85a32085..ada6239a 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -81,8 +81,8 @@ public class ObjectListParameter<C> extends ClassListParameter<C> { } if (List.class.isInstance(obj)) { List<?> l = (List<?>) obj; - ArrayList<C> inst = new ArrayList<C>(l.size()); - ArrayList<Class<? extends C>> classes = new ArrayList<Class<? extends C>>(l.size()); + ArrayList<C> inst = new ArrayList<>(l.size()); + ArrayList<Class<? extends C>> classes = new ArrayList<>(l.size()); for (Object o : l) { // does the given objects class fit? if (restrictionClass.isInstance(o)) { @@ -105,7 +105,7 @@ public class ObjectListParameter<C> extends ClassListParameter<C> { // Did we get a single instance? try { C inst = restrictionClass.cast(obj); - this.instances = new ArrayList<C>(1); + this.instances = new ArrayList<>(1); this.instances.add(inst); return super.parseValue(inst.getClass()); } catch (ClassCastException e) { @@ -118,7 +118,7 @@ public class ObjectListParameter<C> extends ClassListParameter<C> { public List<C> instantiateClasses(Parameterization config) { if (instances == null) { // instantiateClasses will descend itself. - instances = new ArrayList<C>(super.instantiateClasses(config)); + instances = new ArrayList<>(super.instantiateClasses(config)); } else { Parameterization cfg = null; for (int i = 0; i < instances.size(); i++) { @@ -138,6 +138,6 @@ public class ObjectListParameter<C> extends ClassListParameter<C> { } } } - return new ArrayList<C>(instances); + return new ArrayList<>(instances); } }
\ No newline at end of file diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectParameter.java index eff80954..4166d0a2 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ObjectParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Parameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Parameter.java index 6dadbf8f..110633b3 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Parameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Parameter.java @@ -9,7 +9,7 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.ParameterConstra This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/PatternParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/PatternParameter.java index 05c99d2b..b76edbbb 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/PatternParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/PatternParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/RandomParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/RandomParameter.java index 34d01de5..6c0668dd 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/RandomParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/RandomParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/StringParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/StringParameter.java index 06789dba..3a9bbf11 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/StringParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/StringParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/VectorListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/VectorListParameter.java index a9d01f22..906bfbd8 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/VectorListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/VectorListParameter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -29,7 +29,6 @@ import java.util.List; import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID; import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.UnspecifiedParameterException; import de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException; import de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.ParameterConstraint; @@ -178,11 +177,11 @@ public class VectorListParameter extends ListParameter<List<Double>> { if(vectors.length == 0) { throw new WrongParameterValueException("Wrong parameter format! Given list of vectors for parameter \"" + getName() + "\" is empty!"); } - ArrayList<List<Double>> vecs = new ArrayList<List<Double>>(); + ArrayList<List<Double>> vecs = new ArrayList<>(); for(String vector : vectors) { String[] coordinates = SPLIT.split(vector); - ArrayList<Double> vectorCoord = new ArrayList<Double>(); + ArrayList<Double> vectorCoord = new ArrayList<>(); for(String coordinate : coordinates) { try { vectorCoord.add(Double.valueOf(coordinate)); diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/package-info.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/package-info.java index b6ff5216..75d7c5a1 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/package-info.java @@ -12,7 +12,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2012 +Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team |