Something like this, perhaps:
Optional<SimpleEntry> closestPair = elements.stream()
.flatMap(elem -> elements.stream()
.filter(other -> !elem.equals(other))
.map(other -> new SimpleEntry(elem, other))
.min(Comparator.comparingDouble(e -> e.getKey().distance(e.getValue()));
But you may want to extract those inline lambdas as separate methods.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…