/** * Constructs a pair with its left value being {@code left}, and its right value being * {@code right}, or returns an empty pair if both inputs are null. * * @return the constructed pair or an empty pair if both inputs are null. * @since 1.0 */ public static <L, R> Pair<L, R> create(L left, R right) { if (right == null && left == null) { return empty(); } else { return new Pair<>(left, right); } }
/** * Constructs a pair with its right value being {@code right}, or returns an empty pair if * {@code right} is null. * * @return the constructed pair or an empty pair if {@code right} is null. * @since 1.0 */ public static <L, R> Pair<L, R> createRight(R right) { if (right == null) { return empty(); } else { return new Pair<>(null, right); } }
/** * Constructs a pair with its left value being {@code left}, and its right value being * {@code right}, or returns an empty pair if both inputs are null. * * @return the constructed pair or an empty pair if both inputs are null. * @since 1.0 */ public static <L, R> Pair<L, R> create(L left, R right) { if (right == null && left == null) { return empty(); } else { return new Pair<>(left, right); } }
/** * Constructs a pair with its left value being {@code left}, or returns an empty pair if * {@code left} is null. * * @return the constructed pair or an empty pair if {@code left} is null. * @since 1.0 */ public static <L, R> Pair<L, R> createLeft(L left) { if (left == null) { return empty(); } else { return new Pair<>(left, null); } }
/** * Constructs a pair with its left value being {@code left}, or returns an empty pair if * {@code left} is null. * * @return the constructed pair or an empty pair if {@code left} is null. * @since 1.0 */ public static <L, R> Pair<L, R> createLeft(L left) { if (left == null) { return empty(); } else { return new Pair<>(left, null); } }
/** * Constructs a pair with its right value being {@code right}, or returns an empty pair if * {@code right} is null. * * @return the constructed pair or an empty pair if {@code right} is null. * @since 1.0 */ public static <L, R> Pair<L, R> createRight(R right) { if (right == null) { return empty(); } else { return new Pair<>(null, right); } }