/** * Constructs a {@link Pair}. * * @param x the first value of the {@link Pair} * @param y the second value of the {@link Pair} * * @param <X> the type of the first value of the {@link Pair} * @param <Y> the type of the second value of the {@link Pair} * * @return a {@link Pair} */ public static <X, Y> Pair<X, Y> of(X x, Y y) { return new Pair<X, Y>(x, y); }
.filter(pair -> pair.getX() == null) .map(Pair::getY) .forEach(console::withStdOutListener); .filter(pair -> pair.getX() == null) .map(Pair::getY) .forEach(console::withStdErrListener); .filter(pair -> pair.getX() != null) .forEach(pair -> console.withStdOutListener(pair.getX(), pair.getY())); .filter(pair -> pair.getX() != null) .forEach(pair -> console.withStdErrListener(pair.getX(), pair.getY()));
.filter(pair -> pair.getX() == null) .map(Pair::getY) .forEach(console::withStdOutListener); .filter(pair -> pair.getX() == null) .map(Pair::getY) .forEach(console::withStdErrListener); .filter(pair -> pair.getX() != null) .forEach(pair -> console.withStdOutListener(pair.getX(), pair.getY())); .filter(pair -> pair.getX() != null) .forEach(pair -> console.withStdErrListener(pair.getX(), pair.getY()));
/** * Constructs a {@link Pair}. * * @param x the first value of the {@link Pair} * @param y the second value of the {@link Pair} * * @param <X> the type of the first value of the {@link Pair} * @param <Y> the type of the second value of the {@link Pair} * * @return a {@link Pair} */ public static <X, Y> Pair<X, Y> of(X x, Y y) { return new Pair<X, Y>(x, y); }
/** * Add a listener to receive stderr console lines as events that match the specified {@link Predicate}. * * @param predicate the {@link Predicate} to use to match console output lines * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdErrListener(Predicate<String> predicate, EventsApplicationConsole.Listener listener) { stdErrListeners.add(new Pair<>(predicate, listener)); return this; }
/** * Add a listener to receive stdout console lines as events. * * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdOutListener(EventsApplicationConsole.Listener listener) { stdOutListeners.add(new Pair<>(null, listener)); return this; }
/** * Add a listener to receive stderr console lines as events that match the specified {@link Predicate}. * * @param predicate the {@link Predicate} to use to match console output lines * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdErrListener(Predicate<String> predicate, EventsApplicationConsole.Listener listener) { stdErrListeners.add(new Pair<>(predicate, listener)); return this; }
/** * Add a listener to receive stderr console lines as events. * * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdErrListener(EventsApplicationConsole.Listener listener) { stdErrListeners.add(new Pair<>(null, listener)); return this; }
/** * Add a listener to receive stdout console lines as events that match the specified {@link Predicate}. * * @param predicate the {@link Predicate} to use to match console output lines * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdOutListener(Predicate<String> predicate, EventsApplicationConsole.Listener listener) { stdOutListeners.add(new Pair<>(predicate, listener)); return this; }
/** * Add a listener to receive stdout console lines as events that match the specified {@link Predicate}. * * @param predicate the {@link Predicate} to use to match console output lines * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdOutListener(Predicate<String> predicate, EventsApplicationConsole.Listener listener) { stdOutListeners.add(new Pair<>(predicate, listener)); return this; }
/** * Add a listener to receive stdout console lines as events. * * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdOutListener(EventsApplicationConsole.Listener listener) { stdOutListeners.add(new Pair<>(null, listener)); return this; }
/** * Add a listener to receive stderr console lines as events. * * @param listener the {@link EventsApplicationConsole.Listener} * @return this {@link ConsoleBuilder} */ public ConsoleBuilder addStdErrListener(EventsApplicationConsole.Listener listener) { stdErrListeners.add(new Pair<>(null, listener)); return this; }
/** * Add a listener to receive stdout console lines as events * that match the specified {@link Predicate}. * * @param predicate the {@link Predicate} to use to match console output lines * @param listener the {@link Listener} * * @return this {@link EventsApplicationConsole} */ public EventsApplicationConsole withStdOutListener(Predicate<String> predicate, Listener listener) { if (predicate == null) { stdoutListeners.add(new Pair<>((line) -> true, listener)); } else { stdoutListeners.add(new Pair<>(predicate, listener)); } return this; }
/** * Add a listener to receive stdout console lines as events * that match the specified {@link Predicate}. * * @param predicate the {@link Predicate} to use to match console output lines * @param listener the {@link Listener} * * @return this {@link EventsApplicationConsole} */ public EventsApplicationConsole withStdErrListener(Predicate<String> predicate, Listener listener) { if (predicate == null) { stderrListeners.add(new Pair<>((line) -> true, listener)); } else { stderrListeners.add(new Pair<>(predicate, listener)); } return this; }