⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 predicateusage.java

📁 这是一个关于J2EE的开源包common里的许多组件的示例应用程序,可以借鉴.
💻 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 + -