li.strolch.search.SearchExpressions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agent Show documentation
Show all versions of agent Show documentation
Strolch Agent which is the runtime for Strolch
The newest version!
package li.strolch.search;
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import java.util.function.Function;
import java.util.function.Supplier;
import li.strolch.model.Order;
import li.strolch.model.Resource;
import li.strolch.model.StrolchRootElement;
import li.strolch.model.activity.Activity;
import li.strolch.persistence.api.StrolchTransaction;
/**
* Declares specific search expressions, i.e. extracting the relevant data for a where clause
*/
public interface SearchExpressions {
default SearchExpression not(SearchExpression expression) {
return element -> !expression.matches(element);
}
default SearchExpression predicate(Supplier predicate) {
return ExpressionsSupport.predicate(predicate);
}
default SearchExpression predicate(Function predicate) {
return ExpressionsSupport.predicate(predicate);
}
default ExpressionBuilder mapResource(Function extractor) {
return t -> extractor.apply((Resource) t);
}
default ExpressionBuilder mapOrder(Function extractor) {
return t -> extractor.apply((Order) t);
}
default ExpressionBuilder mapActivity(Function extractor) {
return t -> extractor.apply((Activity) t);
}
default ExpressionBuilder id() {
return ExpressionsSupport.id();
}
default SearchExpression id(SearchPredicate predicate) {
return ExpressionsSupport.id(predicate);
}
default ExpressionBuilder name() {
return ExpressionsSupport.name();
}
default SearchExpression name(SearchPredicate predicate) {
return ExpressionsSupport.name(predicate);
}
default ExpressionBuilder date() {
return ExpressionsSupport.date();
}
default SearchExpression date(SearchPredicate predicate) {
return ExpressionsSupport.date(predicate);
}
default ExpressionBuilder state() {
return ExpressionsSupport.state();
}
default SearchExpression state(SearchPredicate predicate) {
return ExpressionsSupport.state(predicate);
}
default ExpressionBuilder param(String paramId) {
return ExpressionsSupport.param(BAG_PARAMETERS, paramId);
}
default ExpressionBuilder relation(String paramId) {
return ExpressionsSupport.param(BAG_RELATIONS, paramId);
}
default ExpressionBuilder param(String bagId, String paramId) {
return ExpressionsSupport.param(bagId, paramId);
}
default SearchExpression param(String paramId, SearchPredicate predicate) {
return ExpressionsSupport.param(BAG_PARAMETERS, paramId, predicate);
}
default SearchExpression param(String bagId, String paramId,
SearchPredicate predicate) {
return ExpressionsSupport.param(bagId, paramId, predicate);
}
default SearchExpression paramNull(String paramId) {
return ExpressionsSupport.paramNull(BAG_PARAMETERS, paramId);
}
default SearchExpression relationNull(String paramId) {
return ExpressionsSupport.paramNull(BAG_RELATIONS, paramId);
}
default SearchExpression paramNull(String bagId, String paramId) {
return ExpressionsSupport.paramNull(bagId, paramId);
}
default ExpressionBuilder relationName(StrolchTransaction tx, String paramId) {
return ExpressionsSupport.relationName(tx, paramId);
}
default SearchExpression relationName(StrolchTransaction tx,
String relationParamId, SearchPredicate predicate) {
return ExpressionsSupport.relationName(tx, relationParamId, predicate);
}
default ExpressionBuilder relationParam(StrolchTransaction tx, String relationParamId, String paramId) {
return ExpressionsSupport.relationParam(tx, relationParamId, BAG_PARAMETERS, paramId);
}
default ExpressionBuilder relationParam(StrolchTransaction tx, String relationParamId, String bagId,
String paramId) {
return ExpressionsSupport.relationParam(tx, relationParamId, bagId, paramId);
}
default SearchExpression relationParam(StrolchTransaction tx,
String relationParamId, String paramId, SearchPredicate predicate) {
return ExpressionsSupport.relationParam(tx, relationParamId, BAG_PARAMETERS, paramId, predicate);
}
default SearchExpression relationParam(StrolchTransaction tx,
String relationParamId, String bagId, String paramId, SearchPredicate predicate) {
return ExpressionsSupport.relationParam(tx, relationParamId, bagId, paramId, predicate);
}
}