You can solve your problem by implementing the first constructor as a static method that delegates your second constructor, for example:
import java.util.Comparator; import java.util.function.Function; public class Test<T,U> { private final Function<U,T> function; private final Comparator<T> comparator; public Test(Function<U,T> function, Comparator<T> comparator) { this.function = function; this.comparator = comparator; } public static <E extends Comparable<E>, V> Test<E,V> withNatOrder(Function<V,E> function) {
A static function does not have access to parameters like T and U, therefore it defines new independent ones. The return type is now Test<E,V> , where E implements Comparable and V is unlimited, like your U-parameter.
source share