I have several groovy scripts used with ScriptRunner - some as validators and some as Behaviours. I have l code lines like this (which are repeated for 10 custom fields:
if (is_a) {
field_a.setHidden(!is_a)
field_b.setHidden(is_a)
// more fields here
} elif (is_b) {
field_a.setHidden(is_b)
field_b.setHidden(!is_b)
// more fields here
} elif (is_c) ...and it can be converted into a method:
showOneFieldHideAllOthers(field_a, is_a)
showOneFieldHideAllOthers(field_b, is_b)
// more calls here
However, I do not want to use the script root mechanism of ScriptRunner - I want all the code to be self-contained in the project.
Questions:
1. Is this possible? Can one use methods in those scripts?
2. If yes, how do I define the signature of the showOneFieldHideAllOthers() - 1st param is a custom field type, 2nd is boolean.
Thanks