public < E > Optional < E > create ( Class < E > type ) { List < Constructor < ? > > constructors = reflect ( ) . constructors ( ) . filter ( declared ( Modifier . PUBLIC ) ) . from ( type ) ; Optional created ; for ( Constructor < ? > constructor : constructors ) { created = tryCreate ( constructor ) ; if ( created . isPresent ( ) ) { return created ; } } return Optional . empty ( ) ; }
Creates a new instance of the given type by looping through its public constructors to find one which all parameters are resolved by the context .