public static final < T > T addList ( Object bean , String property , String hint , BiFunction < Class < T > , String , T > factory ) { Object fieldValue = getValue ( bean , property ) ; if ( fieldValue instanceof List ) { List list = ( List ) fieldValue ; Class [ ] pt = getParameterTypes ( bean , property ) ; T value = ( T ) factory . apply ( pt [ 0 ] , hint ) ; if ( value != null && ! pt [ 0 ] . isAssignableFrom ( value . getClass ( ) ) ) { throw new IllegalArgumentException ( pt [ 0 ] + " not assignable from " + value ) ; } list . add ( value ) ; return value ; } else { throw new IllegalArgumentException ( fieldValue + " not List" ) ; } }
Adds pattern item to end of list using given factory and hint