?? predicateusage.java
字號:
package beanutils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.PredicateUtils;
import org.apache.commons.collections.functors.InstanceofPredicate;
import org.apache.commons.collections.functors.NotNullPredicate;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
/**
* Title : Base Dict Class
* Description : here Description is the function of class, here maybe multirows
* @author <a href="mailto:sunpeng@china.freeborders">kevin</a>
* @Version 1.0
*/
/**
* Class description goes here.
* @version 1.0 2005-9-22
* @author kevin
*/
public class PredicateUsage
{
public static void main(String[] args)
{
demoPredicates();
}
public static void demoPredicates()
{
System.out.println(StringUtils.center(" demoPredicates ", 40, "="));
Predicate p1 = new InstanceofPredicate(String.class);
Predicate p2 = NotNullPredicate.getInstance();
Predicate p3 = new Predicate()
{
public boolean evaluate(Object obj)
{
String str = (String)obj;
return StringUtils.isAlphanumeric(str) && str.length() >= 6 && str.length() <= 10;
}
};
Predicate p4 = PredicateUtils.allPredicate(new Predicate[]{p1, p2, p3});
String input = "===sdf";
Object[] raw = new Object[]{"Is '", input, "' a valid input? ", BooleanUtils.toStringYesNo(p4.evaluate(input)), "."};
System.out.println(StringUtils.join(raw));
System.out.println(StringUtils.repeat("=", 40));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -