Class MatchingUtils


  • public final class MatchingUtils
    extends Object
    • Method Detail

      • isApplicable

        public static int isApplicable​(Type[] args,
                                       Type[] params)
        Discerns whether it would be legal to pass a sequence of references of the given source types to a method with parameters typed according to the specified sequence of destination types.

        An example: suppose you have a method <T extends Number> mergeLists(List<T> list1, List<T> list2). It is legal to pass two List<Integer> instances to the method, but illegal to pass a List<Integer> and List<Double> because T cannot be both Integer and Double simultaneously.

        Parameters:
        args -
        params -
        Returns:
        -1 if the args satisfy the params, otherwise the index of the arg that does not satisfy its parameter.