430 return null;
431 }
432
433 if (type.isAssignableFrom(val.getClass())) {
434 return val;
435 }
436
437 // we currently don't have proper support support for arrays
438 // in FXML so we use lists instead
439 // the user provides us with a list and here we convert it to
440 // array to pass to the constructor
441 if (type.isArray()) {
442 try {
443 return convertListToArray(val, type);
444 } catch (RuntimeException ex) {
445 // conversion failed, maybe the ArrayListWrapper is
446 // used for storing single value
447 }
448 }
449
450 if (Collection.class.isAssignableFrom(type)) {
451 return val;
452 }
453
454 if (ArrayListWrapper.class.equals(val.getClass())) {
455 // user given value is an ArrayList but the constructor doesn't
456 // accept an ArrayList so the ArrayList comes from
457 // the getTemporaryContainer method
458 // we take the first argument
459 List l = (List) val;
460 return l.get(0);
461 }
462
463 return val;
464 }
465
466 private Object createObjectWithExactArguments(Constructor c, Set<String> argumentNames) {
467 Object retObj = null;
468 Object argsForConstruction[] = new Object[argumentNames.size()];
469 Map<String, AnnotationValue> constructorArgsMap = constructorsMap.get(c);
470
471 int i = 0;
472
473 for (String arg : argumentNames) {
474 Class<?> tp = constructorArgsMap.get(arg).getType();
475 Object value = getUserValue(arg, tp);
476 try {
477 argsForConstruction[i++] = BeanAdapter.coerce(value, tp);
478 } catch (Exception ex) {
479 return null;
480 }
481 }
482
|
430 return null;
431 }
432
433 if (type.isAssignableFrom(val.getClass())) {
434 return val;
435 }
436
437 // we currently don't have proper support support for arrays
438 // in FXML so we use lists instead
439 // the user provides us with a list and here we convert it to
440 // array to pass to the constructor
441 if (type.isArray()) {
442 try {
443 return convertListToArray(val, type);
444 } catch (RuntimeException ex) {
445 // conversion failed, maybe the ArrayListWrapper is
446 // used for storing single value
447 }
448 }
449
450 if (ArrayListWrapper.class.equals(val.getClass())) {
451 // user given value is an ArrayList but the constructor doesn't
452 // accept an ArrayList so the ArrayList comes from
453 // the getTemporaryContainer method
454 // we take the first argument
455 List l = (List) val;
456 return l.get(0);
457 }
458
459 if (Collection.class.isAssignableFrom(type)) {
460 return val;
461 }
462
463 return val;
464 }
465
466 private Object createObjectWithExactArguments(Constructor c, Set<String> argumentNames) {
467 Object retObj = null;
468 Object argsForConstruction[] = new Object[argumentNames.size()];
469 Map<String, AnnotationValue> constructorArgsMap = constructorsMap.get(c);
470
471 int i = 0;
472
473 for (String arg : argumentNames) {
474 Class<?> tp = constructorArgsMap.get(arg).getType();
475 Object value = getUserValue(arg, tp);
476 try {
477 argsForConstruction[i++] = BeanAdapter.coerce(value, tp);
478 } catch (Exception ex) {
479 return null;
480 }
481 }
482
|