Java stream: Collectors.maxBy (Double::max) error after map () conversion

Java stream: after map () conversion, Collectors.maxBy (Double::max) reports an error

error message

age is Integer type, (Integer::max), (Integer::min) is correct
salary is Double type, (Double::max), (Double::min) error:
Bad return type in method reference: cannot convert double to int
try rebuid, recompile, mvn clean/compile are all invalid

related codes

@Test
    public void minByOrMaxByTest() {
        // maxBy minBy , Double(salary)maxBy()  TODO
        System.out.println(Employee.EMPLOYEE_LIST.parallelStream().map(Employee::getAge).collect(Collectors.maxBy(Integer::min)).orElse(null));
        System.out.println(Employee.EMPLOYEE_LIST.parallelStream().map(Employee::getAge).collect(Collectors.minBy(Integer::min)).orElse(null));
        System.out.println(Employee.EMPLOYEE_LIST.parallelStream().map(Employee::getSalary).collect(Collectors.minBy(Double::min)));
        System.out.println(Employee.EMPLOYEE_LIST.parallelStream().map(Employee::getSalary).collect(Collectors.maxBy(Double::max)));
    }
    
@Data
@AllArgsConstructor
public class Employee {
    private String name;
    private Integer age;
    private Double salary;
}
Apr.12,2022

public static < T > Collector < T,?, Optional < T > minBy (Comparator comparator) {

return reducing(BinaryOperator.minBy(comparator));

}
Collectors the parameter of the minBy method is Comparator,
Comparator--> int compare (T1, T2); you need to return an int type,
Integer::min and Integer::max match
Double::max and Double::min return double do not match

Menu