All Downloads are FREE. Search and download functionalities are using the official Maven repository.

functionalj.functions.RegExMatchResultStream Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
package functionalj.functions;

import static functionalj.functions.RegExMatchResult.theResults;

import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;

import functionalj.stream.StreamPlus;

@FunctionalInterface
public interface RegExMatchResultStream extends StreamPlus {
    
    public static final RegExMatchResultStream empty = RegExMatchResultStream.from(StreamPlus.empty());
    
    public static RegExMatchResultStream from(Stream stream) {
        if (stream == null)
            return empty;
        
        if (stream instanceof RegExMatchResultStream)
            return (RegExMatchResultStream)stream;
        
        return (RegExMatchResultStream)(()->StreamPlus.from(stream));
    }
    
    public StreamPlus stream();
    
    
    public default StreamPlus toTexts() {
        return pipe(theResults.texts);
    }
    
    
    //-- Filter --
    
    public default RegExMatchResultStream filter(Predicate predicate) {
        return (RegExMatchResultStream)(()->stream().filter(predicate));
    }
    public default RegExMatchResultStream filterNonNull() {
        return (RegExMatchResultStream)(()->stream().filterNonNull());
    }
    
    public default RegExMatchResultStream filterIn(Collection collection) {
        return (RegExMatchResultStream)(()->stream().filterIn(collection));
    }
    
    public default RegExMatchResultStream exclude(Predicate predicate) {
        return (RegExMatchResultStream)(()->stream().exclude(predicate));
    }
    
    public default RegExMatchResultStream excludeIn(Collection collection) {
        return (RegExMatchResultStream)(()->stream().excludeIn(collection));
    }
    
    public default  RegExMatchResultStream filter(Class clzz) {
        return (RegExMatchResultStream)(()->stream().filter(clzz));
    }
    
    public default  RegExMatchResultStream filter(Class clzz, Predicate theCondition) {
        return (RegExMatchResultStream)(()->stream().filter(clzz, theCondition));
    }
    
    public default  RegExMatchResultStream filter(Function mapper, Predicate theCondition) {
        return (RegExMatchResultStream)(()->stream().filter(mapper, theCondition));
    }
    
    public default RegExMatchResultStream filterWithIndex(BiFunction predicate) {
        return (RegExMatchResultStream)(()->stream().filterWithIndex(predicate));
    }
    
    //-- Peek --
    
    public default RegExMatchResultStream peek(Consumer action) {
        return (RegExMatchResultStream)(()->stream().peek(action));
    }
    public default  RegExMatchResultStream peek(Class clzz, Consumer theConsumer) {
        return (RegExMatchResultStream)(()->stream().peek(clzz, theConsumer));
    }
    public default RegExMatchResultStream peek(Predicate selector, Consumer theConsumer) {
        return (RegExMatchResultStream)(()->stream().peek(selector, theConsumer));
    }
    public default  RegExMatchResultStream peek(Function mapper, Consumer theConsumer) {
        return (RegExMatchResultStream)(()->stream().peek(mapper, theConsumer));
    }
    
    public default  RegExMatchResultStream peek(Function mapper, Predicate selector, Consumer theConsumer) {
        return (RegExMatchResultStream)(()->stream().peek(mapper, theConsumer));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy