private static <X extends Executable> X findBest(final X[] candidates, final Object[] args) {
      X exec = candidates[0];
      // if there is only one candidate, return it
      if (candidates.length > 1) {
        Class<?>[] parameters = new Class<?>[args.length];
        // get parameter classes from arguments
        for (int c = 0; c < args.length; ++c) {
          parameters[c] = args[c] == null ? null : args[c].getClass();
        }
        // find "best" executable
        for (X candidate : candidates) {
          if (compareSignatures(parameters, candidate.getParameterTypes()) == 0) {
            exec = candidate;
            break;
          }
        }
      }
      return exec;
    }
Seeks the best executable with or without extra-arguments besides stream.

@param candidates the candidate executors
@param args the arguments
@return the best executable, never null but may be non-suitable for call
@param <X> constructor or method
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/properties/SerializationProxy.java