public static < T extends Executable > Predicate < T > executableHasSameParameterTypesAs ( T reference ) { return candidate -> { if ( candidate == null ) { return false ; } Class < ? > [ ] candidateParameterTypes = candidate . getParameterTypes ( ) ; Class < ? > [ ] referenceParameterTypes = reference . getParameterTypes ( ) ; if ( candidateParameterTypes . length != referenceParameterTypes . length ) { return false ; } for ( int i = 0 ; i < candidateParameterTypes . length ; i ++ ) { if ( ! candidateParameterTypes [ i ] . equals ( referenceParameterTypes [ i ] ) ) { return false ; } } return true ; } ; }
Checks if a candidate executable has the same parameter type as the specified reference executable .