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

📄 negationasfailure.java

📁 一个关于java 的常用工具包
💻 JAVA
字号:
package org.jutil.predicate;import java.util.List;import java.util.ArrayList;/*@ model import org.jutil.java.collections.Collections; @*//** * <p>A class of predicates that wrap another predicate and treat the  * occurrence of an exception in * <a href="NegationAsFailure.html#eval(java.lang.Object)"><code>eval()</code></a> * as <code>false</code>.</p> * * <center><img src="doc-files/NegationAsFailure.png"/></center> * * <p>Note that if you wrap a NegationAsFailure object in another predicate, * you will not get the same result as when switching the wrapping predicate * and the NegationAsFailure. E.g. <code>new Not(new NegationAsFailure(predicate))</code> * will not always return the same value as <code>new NegationAsFailure(new Not(predicate))</code>.</p> * * @path    $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/predicate/NegationAsFailure.java,v $ * @version $Revision: 1.3 $ * @date    $Date: 2002/07/21 16:06:38 $ * @state   $State: Exp $ * @author  Marko van Dooren * @release $Name:  $ */public class NegationAsFailure extends TotalPredicate {	  /* The revision of this class */    public final static String CVS_REVISION ="$Revision: 1.3 $";        /**	 * Initialize a new NegationAsFailure with the given predicate.	 *	 * @param predicate	 *        The predicate to be wrapped.	 */ /*@	 @ public behavior	 @	 @ pre predicate != null;	 @	 @ post getPredicate() == predicate;	 @*/	public NegationAsFailure(Predicate predicate) {		$predicate = predicate;	}  /*@	  @ also public behavior		@		@ post getPredicate().isValidElement(object) ==> \result == getPredicate().eval(object);		@ post ! getPredicate().isValidElement(object) ==> false;		@*/	public boolean eval(Object object) {		//MVDMVDMVD: the spec is not correct, FIX IT		try {			return $predicate.eval(object);		}		catch(Exception exc) {			return false;		}	}	/**	 * Return the wrapped predicate.	 */ /*@   @ public behavior 	 @	 @ post \result == getSubPredicates().get(1);	 @*/	public Predicate getPredicate() {		return $predicate;	} /*@	 @ also public behavior	 @	 @ post Collections.containsExplicitly(\result, getPredicate());	 @ post \result.size() == 1;	 @*/	public List getSubPredicates() {		List result = new ArrayList();		result.add($predicate);		return result;	}  /**	 * See superclass	 */	public int nbSubPredicates() {		return 1;	}  /**   * The wrapped predicate.   */ /*@	 @ private invariant $predicate != null;	 @ private invariant $predicate != this;	 @*/	private Predicate $predicate;}/* * <copyright>Copyright (C) 1997-2001. 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 + -