cn.allbs.hj212.core.ReaderMatch Maven / Gradle / Ivy
package cn.allbs.hj212.core;
import cn.allbs.hj212.lambda.RunnableWithThrowable;
import cn.allbs.hj212.lambda.SupplierWithThrowable;
import java.io.IOException;
import java.util.Optional;
/**
* 功能: 字符读取匹配
*
* @author chenQi
*/
public interface ReaderMatch {
/**
* 字符读取流
*
* @return ParentStream
*/
ParentStream done();
/**
* 匹配
*
* @return 匹配到
* @throws IOException
*/
Optional match() throws IOException;
static SupplierWithThrowable, IOException> alwaysReturnPresent() {
return () -> Optional.of(true);
}
static SupplierWithThrowable, IOException> alwaysReturnNotPresent() {
return Optional::empty;
}
static SupplierWithThrowable, IOException> alwaysReturnPresentRunable(RunnableWithThrowable runnable) {
return () -> {
runnable.run();
return Optional.of(true);
};
}
static SupplierWithThrowable, IOException> alwaysReturnNotPresentRunable(RunnableWithThrowable runnable) {
return () -> {
runnable.run();
return Optional.empty();
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy