Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Adding Tools to HIPE | ||||||||
Line: 50 to 50 | ||||||||
getSignature().setPrimeInput(prime) } } | ||||||||
Deleted: | ||||||||
< < | public void setParameterValidator(ParameterValidator validator) { _validator = validator; } | |||||||
Prime input validation | ||||||||
Line: 63 to 60 | ||||||||
You can write a ParameterValidator to do just that:
prime=new TaskParameter("spectrum",SpecificProduct.class) | ||||||||
Changed: | ||||||||
< < | validator=new ParameterValidator() { public boolean isValid(Object value) { SpecificProduct s=(SpecificProduct)value; ...logic that would validate the contents of the value... } | |||||||
> > | prime.setValidator(new ParameterValidatorAdapter() { | |||||||
public void validate(Object value) throws ParameterValidationException { | ||||||||
Changed: | ||||||||
< < | if (isValid(value)) throw new ParameterValidationException(reason); | |||||||
> > | SpecificProduct s=(SpecificProduct)value; if (! (logic that would validate the contents of the value...)) { throw new ParameterValidationException(reason); | |||||||
} } | ||||||||
Added: | ||||||||
> > | }); | |||||||
In other words, rather than writing this logic within the pre-amble or execution block of your task, we recommend you to move that logic into the parameter validation. This way we achieve two things: |