dk.apaq.framework.criteria.Rules Maven / Gradle / Ivy
package dk.apaq.framework.criteria;
import dk.apaq.framework.criteria.rules.AndRule;
import dk.apaq.framework.criteria.rules.BetweenRule;
import dk.apaq.framework.criteria.rules.CompareRule;
import dk.apaq.framework.criteria.rules.ContainsRule;
import dk.apaq.framework.criteria.rules.IsNullRule;
import dk.apaq.framework.criteria.rules.LikeRule;
import dk.apaq.framework.criteria.rules.NotRule;
import dk.apaq.framework.criteria.rules.OrRule;
/**
*
* @author krog
*/
public class Rules {
public static Rule and(Rule ... filters) {
return new AndRule(filters);
}
public static Rule or(Rule ... filters) {
return new OrRule(filters);
}
public static Rule not(Rule filter) {
return new NotRule(filter);
}
public static Rule not(String propertyId, Object value) {
return new NotRule(new CompareRule(propertyId, value, CompareRule.CompareType.Equals));
}
public static Rule equals(String propertyId, Object value) {
return new CompareRule(propertyId, value, CompareRule.CompareType.Equals);
}
public static Rule lessThan(String propertyId, Object value) {
return new CompareRule(propertyId, value, CompareRule.CompareType.LessThan);
}
public static Rule lessOrEqual(String propertyId, Object value) {
return new CompareRule(propertyId, value, CompareRule.CompareType.LessOrEqual);
}
public static Rule greaterThan(String propertyId, Object value) {
return new CompareRule(propertyId, value, CompareRule.CompareType.GreaterThan);
}
public static Rule greaterOrEqual(String propertyId, Object value) {
return new CompareRule(propertyId, value, CompareRule.CompareType.GreaterOrEqual);
}
public static Rule like(String propertyId, String value) {
return new LikeRule(propertyId, value);
}
public static Rule like(String propertyId, String value, boolean caseSensitive) {
return new LikeRule(propertyId, value, caseSensitive);
}
public static Rule isNull(String propertyId) {
return new IsNullRule(propertyId);
}
public static Rule between(String propertyId, Object from, Object to) {
return new BetweenRule(propertyId, from, to);
}
public static Rule contains(String propertyId, Object value) {
return new ContainsRule(propertyId, value);
}
}