*
* @param element
* @return
*/
public Callback<Void, FXFormNode> getFactory(Element element) {
ReadOnlyPropertyFieldElement property = ((ReadOnlyPropertyFieldElement) element);
// check field annotation
if (property.getField().getAnnotation(FormFactory.class) != null) {
// use factory provided by the annotation
try {
return property.getField().getAnnotation(FormFactory.class).value().newInstance();
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to get new instance for " + property.getField().getAnnotation(FormFactory.class), e);
}
}
// check FormFactory annotation
if (ObjectProperty.class.isAssignableFrom(property.getField().getType())) {
try {
Class genericClass = property.getGenericType();
if (genericClass.getAnnotation(FormFactory.class) != null) {
return ((FormFactory) genericClass.getAnnotation(FormFactory.class)).value().newInstance();
}
} catch (Exception e) {
// ignore