LongRangeSet (@Nullable RelationType relation) { if (isEmpty() || relation == null) return null; return switch (relation) { case EQ -> this; case NE -> { long min = min(); if (min == max()) yield all().without(min); yield all(); } case GT -> { long min = min(); yield min == Long.MAX_VALUE ? empty() : range(min + 1, Long.MAX_VALUE); } case GE -> range(min(), Long.MAX_VALUE); case LE -> range(Long.MIN_VALUE, max()); case LT -> { long max = max(); yield max == Long.MIN_VALUE ? empty() : range(Long.MIN_VALUE, max - 1); } default -> null; }; }