1 package jalview.ws.jws2;
3 import java.util.HashSet;
6 import compbio.metadata.*;
7 public class ParameterUtils
10 public static Option copyOption(Option option)
12 Option copy = new Option(option.getName(), option.getDescription());
13 setOptionFrom(copy, option);
16 public static void setOptionFrom(Option copy, Option option)
18 copy.setName(option.getName());
19 copy.setDescription(option.getDescription());
20 copy.setFurtherDetails(option.getFurtherDetails());
21 copy.setRequired(option.isRequired());
22 List<String> names = option.getOptionNames();
26 HashSet<String> st = new HashSet();
28 copy.setOptionNames(st);
30 copy.addOptionNames(names.toArray(new String[]{}));
34 if (option.getDefaultValue()!=null)
36 copy.setDefaultValue(option.getDefaultValue());
38 } catch (Exception ex)
44 public static ValueConstrain copyValueConstrain(ValueConstrain vc)
46 try {ValueConstrain copy = new ValueConstrain();
47 if (vc.getMax()!=null) {
48 copy.setMax(vc.getMax().toString());
50 if (vc.getMin()!=null) {
51 copy.setMin(vc.getMin().toString());
53 if (vc.getType()!=null) {
54 copy.setType(vc.getType());
61 throw new Error("Implementation error: could not copy ValueConstrain!");
64 public static Parameter copyParameter(Parameter parameter)
66 Parameter copy = new Parameter(parameter.getName(), parameter.getDescription());
67 if (parameter.getValidValue()!=null) {
68 copy.setValidValue(copyValueConstrain(parameter.getValidValue()));
70 List<String> pv = parameter.getPossibleValues();
73 copy.addPossibleValues(pv.toArray(new String[]{}));
75 setOptionFrom(copy, parameter);