1 package eu
.etaxonomy
.taxeditor
.handler
;
3 import java
.util
.ArrayList
;
7 import org
.eclipse
.core
.commands
.AbstractParameterValueConverter
;
8 import org
.eclipse
.core
.commands
.ParameterValueConversionException
;
11 * Converts either a single {@link UUID} or a list of UUIDSs to a string representation
18 public class UuidsParameterTypeConverter
extends AbstractParameterValueConverter
{
20 private static final String SEPARATOR
= ",";
22 public UuidsParameterTypeConverter() {
26 public Object
convertToObject(String parameterValue
) throws ParameterValueConversionException
{
27 if(parameterValue
.endsWith(SEPARATOR
)){
28 List
<UUID
> uuids
= new ArrayList
<UUID
>();
29 String
[] split
= parameterValue
.split(SEPARATOR
);
30 for (String string
: split
) {
31 uuids
.add(UUID
.fromString(string
));
36 return UUID
.fromString(parameterValue
);
41 public String
convertToString(Object parameterValue
) throws ParameterValueConversionException
{
42 if(parameterValue
instanceof List
){
43 List list
= (List
)parameterValue
;
44 String stringList
= "";
45 for (Object object
: list
) {
46 stringList
+= parameterValue
.toString()+SEPARATOR
;
49 else if(parameterValue
instanceof UUID
){
50 return parameterValue
.toString();
53 throw new ParameterValueConversionException("Parameter is of wrong type: "+parameterValue
.getClass().toString());