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

📄 totalpredicate.java

📁 一个关于java 的常用工具包
💻 JAVA
字号:
package org.jutil.predicate;import java.util.Collection;import java.util.Iterator;import java.util.ConcurrentModificationException;/** * <p>A class of Predicates that do not throw exceptions.</p> *  * <center><img src="doc-files/TotalPredicate.png"/></center> * * <p>If your predicate don't throw exceptions, you should subclass  * TotalPredicate. This saves the client from writing useless try-catch  * blocks.</p> * * <p>Typically, this class will be used as an anonymous inner class as follows:</p> * <pre> *TotalPredicate myPredicate = new TotalPredicate() { *            public boolean eval(Object o) { *              //calculate boolean value *              //using the given object *            } * *            public int nbSubPredicates() { *              // ... *            } * *            public List getSubPredicates() { *              // ... *            } *          }; * </pre> * * <p>Note that if your predicate doesn't contain any sub predicates, * it should extend <a href="PrimitiveTotalPredicate.html"><code>PrimitiveTotalPredicate</code></a> * instead of this class.</p> * * @path    $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/predicate/TotalPredicate.java,v $ * @version $Revision: 1.3 $ * @date    $Date: 2002/09/07 09:24:11 $ * @state   $State: Exp $ * @author  Marko van Dooren * @release $Name:  $ */public abstract class TotalPredicate extends AbstractPredicate {  /* The revision of this class */  public final static String CVS_REVISION ="$Revision: 1.3 $";     /*@   @ also public behavior   @   @ // A total predicate never throws an exception.   @ signals (Exception) false;   @*/  public abstract boolean eval(Object object); /*@	 @ also public behavior	 @	 @ post \result == true;	 @	 @ public model boolean isValidElement(Object o);	 @*/ /*@   @ also public behavior	 @	 @ // No Exception can be thrown	 @ signals (Exception) false;	 @*/  public boolean exists(Collection collection) {		try {			return super.exists(collection);		}		catch(Exception exc) {			throw new Error("Exception occurred in org.jutil.predicate.total.TotalPredicate.exists");		}  } /*@   @ also public behavior	 @	 @ // No Exception can be thrown	 @ signals (Exception) false;	 @*/  public boolean forall(Collection collection) {		try {			return super.forall(collection);		}		catch(Exception exc) {			throw new Error("Exception occurred in org.jutil.predicate.total.TotalPredicate.forall");		}  } /*@   @ also public behavior	 @	 @ // No Exception can be thrown	 @ signals (Exception) false;	 @*/  public int count(Collection collection) {		try {			return super.count(collection);		}		catch(Exception exc) {			throw new Error("Exception occurred in org.jutil.predicate.total.TotalPredicate.count");		}  } /*@   @ also public behavior	 @	 @ // No Exception can be thrown	 @ signals (Exception) false;	 @*/  public void filter(Collection collection) {		// The backup costs too much, we don't want to do that here.    if (collection != null) {      Iterator iter = collection.iterator();      while (iter.hasNext()) {        if (! eval(iter.next())) {          iter.remove();        }      }    }  }}/* * <copyright>Copyright (C) 1997-2002. This software is copyrighted by  * the people and entities mentioned after the "@author" tags above, on  * behalf of the JUTIL.ORG Project. The copyright is dated by the dates  * after the "@date" tags above. All rights reserved. * This software is published under the terms of the JUTIL.ORG Software * License version 1.1 or later, a copy of which has been included with * this distribution in the LICENSE file, which can also be found at * http://org-jutil.sourceforge.net/LICENSE. This software is distributed  * WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  * See the JUTIL.ORG Software License for more details. For more information, * please see http://org-jutil.sourceforge.net/</copyright> */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -