Review generated reading merger

from Generics
Java 25 LTS advanced 6 min 4 issues to find

Review this generated reading merge before it becomes a shared collection utility.

Append a same-typed source to the caller-owned destination, return all destination readings without duplicates in original encounter order, never mutate the source, handle an empty source, and keep the library method silent.

Java
import java.util.ArrayList;
import java.util.List;

public class GeneratedReadings {
    static <T extends Number & Comparable<? super T>> List<T> mergeDistinct(
            List<T> destination, List<T> source) {
        source.sort(null);
        destination.addAll(source);
        T max = source.getLast();
        List<T> unique = new ArrayList<>();
        for (T value : destination) {
            if (!unique.contains(value)) {
                unique.add(value);
            }
        }
        System.out.println("max: " + max);
        return unique;
    }
}

generated code is illustrative, not from any one model

Open in playground
Report an error