*/
if (selectionAnnotation != null && selectionAnnotation.options().length > 0) {
int i = 0;
for (com.citytechinc.cq.component.annotations.Option curOptionAnnotation : selectionAnnotation.options()) {
if (StringUtils.isEmpty(curOptionAnnotation.value())) {
throw new InvalidComponentFieldException(
"Selection Options specified in the selectionOptions Annotation property must include a non-empty text and value attribute");
}
String qtip = null;
if (StringUtils.isNotEmpty(curOptionAnnotation.qtip())) {
qtip = curOptionAnnotation.qtip();
}
OptionParameters parameters = new OptionParameters();
parameters.setFieldName(OPTION_FIELD_NAME_PREFIX + (i++));
parameters.setText(curOptionAnnotation.text());
parameters.setValue(curOptionAnnotation.value());
parameters.setQtip(qtip);
options.add(new Option(parameters));
}
}
/*
* If options were not specified by the annotation then we check to see
* if the field is an Enum and if so, the options are pulled from the
* Enum definition
*/
else if (getType().isEnum()) {
int i = 0;
for (Object curEnumObject : parameters.getClassLoader().loadClass(getType().getName()).getEnumConstants()) {
Enum<?> curEnum = (Enum<?>) curEnumObject;
try {
options.add(buildSelectionOptionForEnum(curEnum, parameters.getClassPool(),
OPTION_FIELD_NAME_PREFIX + (i++)));
} catch (SecurityException e) {
throw new InvalidComponentFieldException("Invalid Enum Field", e);
} catch (NoSuchFieldException e) {
throw new InvalidComponentFieldException("Invalid Enum Field", e);
}
}
}
return options;