public static <T, R> List<T> intersection(List<T> list1, List<T> list2, Function<T, R> keyExtractor) {
        if (CollectionUtils.isEmpty(list1) || CollectionUtils.isEmpty(list2)) {
            return new ArrayList<>();
        }

        Map<R, T> map1 = toMap(list1, keyExtractor);
        Map<R, T> map2 = toMap(list2, keyExtractor);
        return map2.entrySet().stream()
                .filter(entry -> map1.containsKey(entry.getKey()))
                .map(Map.Entry::getValue)
                .collect(Collectors.toList());
    }
Return a list of elements in both list1 and list2 by a specified key
@param list1
@param list2
@param keyExtractor Key extract function
@return List of elements in both list1 and list2 by a specified key
@param <T> Element type
@param <R> Key type
inlong-common/src/main/java/org/apache/inlong/common/util/ListUtil.java