X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/05a5c0f87b3270e408a66fbaad3008de145a11c8..c295928b98f855b52ad7b7bd4e3a280687b559c3:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/UuidsParameterTypeConverter.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/UuidsParameterTypeConverter.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/UuidsParameterTypeConverter.java index e23482714..ca37917a7 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/UuidsParameterTypeConverter.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/UuidsParameterTypeConverter.java @@ -1,12 +1,14 @@ package eu.etaxonomy.taxeditor.handler; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import org.eclipse.core.commands.AbstractParameterValueConverter; import org.eclipse.core.commands.ParameterValueConversionException; /** - * Converts {@link UUID}s to a string representation + * Converts either a single {@link UUID} or a list of UUIDSs to a string representation * and vica versa. * * @author pplitzner @@ -15,17 +17,42 @@ import org.eclipse.core.commands.ParameterValueConversionException; */ public class UuidsParameterTypeConverter extends AbstractParameterValueConverter { + private static final String SEPARATOR = ","; + public UuidsParameterTypeConverter() { } @Override public Object convertToObject(String parameterValue) throws ParameterValueConversionException { - return UUID.fromString(parameterValue); + if(parameterValue.endsWith(SEPARATOR)){ + List uuids = new ArrayList(); + String[] split = parameterValue.split(SEPARATOR); + for (String string : split) { + uuids.add(UUID.fromString(string)); + } + return uuids; + } + else{ + return UUID.fromString(parameterValue); + } } @Override public String convertToString(Object parameterValue) throws ParameterValueConversionException { - return parameterValue.toString(); + if(parameterValue instanceof List){ + List list = (List)parameterValue; + String stringList = ""; + for (Object object : list) { + stringList += parameterValue.toString()+SEPARATOR; + } + } + else if(parameterValue instanceof UUID){ + return parameterValue.toString(); + } + else{ + throw new ParameterValueConversionException("Parameter is of wrong type: "+parameterValue.getClass().toString()); + } + return null; } -} \ No newline at end of file +}