Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
<-- ANALYTICS CODE - DO NOT EDIT --> <-- Google Analytics script BEGIN --> <-- Google Analytics script END --> | ||||||||
Line: 182 to 182 | ||||||||
You cannot set multiple data types for a parameter, but you can achieve the same effect by using one of the following workarounds:
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
For example, this is a task whose primary input accepts String, Integer and Product:
.public class CombinedTask extends Task { private static final String TASKNAME = "combined"; private static final String PRIME = "input"; /** Jython doc string */ public static PyString __doc__; /**Constructor*/ public CombinedTask() { super(TASKNAME); addTaskParameter(TaskUtil.buildParameter(PRIME, Object.class, INPUT, MANDATORY, null, NULL_NOT_ALLOWED, "String, Integer or Product")); getParameter(PRIME).setParameterValidator(new ParameterValidatorAdapter() { @Override public void validate(Object value) throws ParameterValidationException { if (value instanceof String || value instanceof Integer || value instanceof Product) { return; } throw new ParameterValidationException("Not String, Integer or Product but " + value.getClass()); } }); setDescription("task to test object parameters"); __doc__ = TaskUtil.makeDoc(this); } @Override public void execute() { Object prime = getValue(PRIME); if (prime instanceof String) { System.out.println("A String " + prime); } else if (prime instanceof Integer) { System.out.println("An Integer " + prime); } else { System.out.println("A Product " + prime); } } }
| |||||||
Cleaning of parameters after execution |