
net.pincette.rs.Last Maven / Gradle / Ivy
package net.pincette.rs;
import java.util.concurrent.Flow.Processor;
/**
* Emits the last value it receives and then completes the stream.
*
* @param the value type.
* @author Werner Donn\u00e9
* @since 1.4
*/
public class Last extends PassThrough {
private T lastValue;
public static Processor last() {
return new Last<>();
}
@Override
public void onComplete() {
if (lastValue != null) {
super.onNext(lastValue);
}
super.onComplete();
}
@Override
public void onNext(final T value) {
lastValue = value;
more();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy