当前位置: 首页>>代码示例>>Java>>正文


Java Predicate.eval方法代码示例

本文整理汇总了Java中org.aikodi.rejuse.predicate.Predicate.eval方法的典型用法代码示例。如果您正苦于以下问题:Java Predicate.eval方法的具体用法?Java Predicate.eval怎么用?Java Predicate.eval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.aikodi.rejuse.predicate.Predicate的用法示例。


在下文中一共展示了Predicate.eval方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findFirst

import org.aikodi.rejuse.predicate.Predicate; //导入方法依赖的package包/类
public static <T,E extends Exception> T findFirst(Collection<T> collection, Predicate<? super T,E> predicate) throws E {
  Iterator<T> iterator = collection.iterator();
  while(iterator.hasNext()) {
    T t = iterator.next();
    if(predicate.eval(t)) {
      return t;
    }
  }
  return null;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:11,代码来源:CollectionOperations.java

示例2: filter

import org.aikodi.rejuse.predicate.Predicate; //导入方法依赖的package包/类
public <E extends Exception> void filter(Predicate<? super Edge<V>,E> predicate) throws E {
	for(Edge<V> edge: edges()) {
		if(! predicate.eval(edge)) {
			edge.terminate();
		}
	}
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:8,代码来源:Graph.java

示例3: involvedTypeParameters

import org.aikodi.rejuse.predicate.Predicate; //导入方法依赖的package包/类
public List<TypeParameter> involvedTypeParameters(JavaTypeReference tref) throws LookupException {
	Predicate<BasicJavaTypeReference, LookupException> predicate = 
	    object ->  parent().typeParameters().contains(object.getDeclarator());
	List<BasicJavaTypeReference> list = tref.descendants(BasicJavaTypeReference.class, predicate);
	if((tref instanceof BasicJavaTypeReference) && predicate.eval((BasicJavaTypeReference) tref)) {
		list.add((BasicJavaTypeReference) tref);
	}
	List<TypeParameter> parameters = new ArrayList<TypeParameter>();
	for(BasicJavaTypeReference cref: list) {
		parameters.add((TypeParameter) cref.getDeclarator());
	}
	return parameters;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:14,代码来源:FirstPhaseConstraint.java

示例4: replace

import org.aikodi.rejuse.predicate.Predicate; //导入方法依赖的package包/类
/**
	 * Replace all references to 'declarator' in 'in' with copies of 'replacement'.
	 * @param replacement
	 * @param declarator
	 * @param in
	 * @param kind
	 * @return
	 * @throws LookupException
	 */
	public static <E extends Element> E replace(TypeReference replacement, final Declaration declarator, E in, Class<E> kind) throws LookupException {
		ObjectOrientedLanguage lang = in.language(ObjectOrientedLanguage.class);
		E result = in;
		Predicate<BasicTypeReference, LookupException> predicate = object -> object.getDeclarator().sameAs(declarator);
		List<BasicTypeReference> crefs = in.descendants(BasicTypeReference.class, 
				predicate);
		if(in instanceof BasicTypeReference) {
			BasicTypeReference in2 = (BasicTypeReference) in;
			if(predicate.eval(in2)) {
				crefs.add(in2);
			}
		}
		for(BasicTypeReference cref: crefs) {
			TypeReference substitute;
			Element oldParent = replacement.parent();
			if(replacement.isDerived()) {
//				replacement.setUniParent(null);
			  substitute = lang.createNonLocalTypeReference(Util.clone(replacement),oldParent);
			  substitute.setOrigin(replacement);
			} else {
			  substitute = lang.createNonLocalTypeReference(Util.clone(replacement),oldParent);
			}
			if(! cref.isDerived()) {
				SingleAssociation crefParentLink = cref.parentLink();
				crefParentLink.getOtherRelation().replace(crefParentLink, substitute.parentLink());
			} else {
				substitute.setUniParent(in.parent());
			}
			if(cref == in) {
				if(kind.isInstance(substitute)) {
				  result = (E) substitute;
				} else {
					throw new ChameleonProgrammerException("The type reference passed to replace must be replaced as a whole, but the kind that was given is more specific than the newly created type reference.");
				}
			}
		}
		return result;
	}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:48,代码来源:NonLocalJavaTypeReference.java

示例5: nearestIncluding

import org.aikodi.rejuse.predicate.Predicate; //导入方法依赖的package包/类
default <X extends T, E extends Exception> X nearestIncluding(Class<X> kind, Predicate<X, E> predicate, T el) throws E {
	while ((el != null) && ((! kind.isInstance(el)) || (! predicate.eval((X)el)))) {
     el = tree(el).parent();
   }
   return (X) el;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:7,代码来源:TreeStructure.java


注:本文中的org.aikodi.rejuse.predicate.Predicate.eval方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。