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


Java UniversalPredicate类代码示例

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


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

示例1: post

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
/**
  * Recursively return all descendants of this element that satisfy the given predicate.
  * 
  * @param predicate A predicate that determines which descendants are returned.
  */
/*@
  @ default behavior
  @
  @ pre predicate != null;
  @
  @ post \result != null;
  @ post (\forall Element e; ; \result.contains(e) <==> descendants().contains(e) && predicate.eval(e));
  @*/
default <X extends T, E extends Exception> List<X> descendants(UniversalPredicate<X,E> predicate) throws E, N {
	List<X> result = children(predicate);
	predicate.filter(result);
	for (T e : children()) {
		result.addAll(tree(e).descendants(predicate));
	}
	return result;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:22,代码来源:TreeStructure.java

示例2: packagePredicate

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<? super Type,Nothing> packagePredicate(AnalysisOptions options) {
	List<String> packageNames = packageNames((DependencyOptions) options);
	UniversalPredicate<? super Type,Nothing> result;
	if(packageNames.isEmpty()) {
		result = new True();
	} else {
		result = new False();
		for(final String string: packageNames) {
			result = result.or(
					new UniversalPredicate<Type,Nothing>(Type.class) {

				@Override
				public boolean uncheckedEval(Type object) {
					return new GlobPredicate(string,'.').eval(object.nearestAncestor(NamespaceDeclaration.class).namespace().fullyQualifiedName());
				}

			}).makeUniversal(Type.class);
		}
	}
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:22,代码来源:DependencyAnalysisTool.java

示例3: crossReferenceHierarchyFilter

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<CrossReference,Nothing> crossReferenceHierarchyFilter(final AnalysisOptions options, final ObjectOrientedView view) throws LookupException {
	final UniversalPredicate<Type, Nothing> hierarchyPredicate = hierarchyPredicate(options, view);
	UniversalPredicate<CrossReference,LookupException> unguarded = new UniversalPredicate<CrossReference,LookupException>(CrossReference.class) {

		@Override
		public boolean uncheckedEval(CrossReference object) throws LookupException{
			Declaration element = object.getElement();
			Type t = element.lexical().nearestAncestorOrSelf(Type.class);
			if(t != null) {
				return hierarchyPredicate.eval(t);
			} else {
				return true;
			}
		}
	};
	UniversalPredicate<CrossReference, Nothing> result = unguarded.guard(true);
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:19,代码来源:DependencyAnalysisTool.java

示例4: crossReferenceTargetType

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<CrossReference,Nothing> crossReferenceTargetType(final AnalysisOptions options, final ObjectOrientedView view) throws LookupException {
	final UniversalPredicate<Type, Nothing> targetPredicate = targetTypePredicate(options, view);
	UniversalPredicate<CrossReference,LookupException> unguarded = new UniversalPredicate<CrossReference,LookupException>(CrossReference.class) {

		@Override
		public boolean uncheckedEval(CrossReference object) throws LookupException{
			Declaration element = object.getElement();
			Type t = element.lexical().nearestAncestorOrSelf(Type.class);
			if(t != null) {
				return targetPredicate.eval(t);
			} else {
				return true;
			}
		}
	};
	UniversalPredicate<CrossReference, Nothing> result = unguarded.guard(true);
	return result;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:19,代码来源:DependencyAnalysisTool.java

示例5: targetTypePredicate

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<Type,Nothing> targetTypePredicate(AnalysisOptions options, ObjectOrientedView view) throws LookupException {
	UniversalPredicate<Type,Nothing> filter = SOURCE_TYPE;
	List<String> ignored = ignoredTargets((DependencyOptions) options);
	for(String fqn: ignored) {
			Type type = view.findType(fqn);
			filter = filter.and(new UniversalPredicate<Type,Nothing>(Type.class) {

				@Override
				public boolean uncheckedEval(Type t) throws Nothing {
					return ! t.getFullyQualifiedName().equals(fqn);
				}
				
			});
	}
	return filter;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:17,代码来源:DependencyAnalysisTool.java

示例6: noSuperTypes

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
private PredicateSelector<? super Dependency<? super Element, ? super CrossReference, ? super Declaration>> noSuperTypes() {
  return new CheckboxPredicateSelector<Dependency<?,?,?>>(

      new UniversalPredicate<Dependency, Nothing>(Dependency.class) {

        @Override
        public boolean uncheckedEval(Dependency t) throws Nothing {
          Element target = (Element) t.target();
          Element source = (Element)t.source();
          if(source instanceof Type && target instanceof Type) {
            try {
              return ! ((Type)source).subtypeOf((Type) target);
            } catch (LookupException e) {
            }
          }
          return true;
        }
      }, "Ignore super types",true);
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:20,代码来源:JavaDependencyOptions.java

示例7: nearestAncestor

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
public <X extends T, E extends Exception> X nearestAncestor(T element, UniversalPredicate<X,E> predicate) throws E {
	T el = parent(element);
	while ((el != null) && (! predicate.eval((T)el))) {
		el = tree(el).parent(el);
	}
	return (X) el;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:8,代码来源:FunctionalTreeStructure.java

示例8: nearestAncestorOrSelf

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
public <X extends T, E extends Exception> X nearestAncestorOrSelf(T element, UniversalPredicate<X, E> predicate) throws E {
	T el = element;
	while ((el != null) && (! predicate.eval((T)el))) {
		el = tree(el).parent(el);
	}
	return (X) el;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:8,代码来源:FunctionalTreeStructure.java

示例9: parent

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
/**
  * Return the nearest ancestor of type T that satisfies the given predicate. Null if no such ancestor can be found.
  * 
  * @param <X>
  *        The type of the ancestor to be found
  * @param <E>
  *        The type of the exception that can be thrown by the predicate.
  * @return
  */
/*@
  @ default behavior
  @
  @ post parent() == null ==> \result == null;
  @ post parent() != null && predicate.eval(parent()) ==> \result == parent();
  @ post parent() != null && (! predicate.eval((T)parent())) 
  @          ==> \result == parent().nearestAncestor(predicate);
  @*/
 default <X extends T, E extends Exception> X nearestAncestor(UniversalPredicate<X,E> predicate) throws E {
   return nearest(predicate, parent());
 }
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:21,代码来源:TreeStructure.java

示例10: farthest

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
default <E extends Exception, X extends T> X farthest(UniversalPredicate<X, E> predicate, T el) throws E {
  // Find the first one, including self
  el = tree(el).nearestAncestorOrSelf(predicate);
  X anc = (X)el;
  // Find the rest. We must now skip self because it already matched.
  while(el != null) {
    el = tree(el).nearestAncestor(predicate);
    if(el != null) {
      anc = (X) el;
    }
  }
  return anc;
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:14,代码来源:TreeStructure.java

示例11: descendants

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
/**
  * Check whether this element has a descendant that satisfies the given predicate.
  * 
  * @param predicate The predicate of which must be determined whether any descendants satisfy it.
  * @throws Exception 
  */
/*@
  @ default behavior
  @
  @ pre predicate != null;
  @
  @ post \result == (\exists T t; descendants().contains(t); predicate.eval(t));
  @*/
 default <X extends T, E extends Exception> boolean hasDescendant(UniversalPredicate<X,E> predicate) throws Exception {
   return (! children(predicate).isEmpty()) || exists(children(), c -> tree(c).hasDescendant(predicate));
 }
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:17,代码来源:TreeStructure.java

示例12: crossReferenceNonInheritanceFilter

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<CrossReference<?>,Nothing> crossReferenceNonInheritanceFilter() {
	return new UniversalPredicate(CrossReference.class) {

		@Override
		public boolean uncheckedEval(Object object) {
			return ((CrossReference)object).nearestAncestor(InheritanceRelation.class) == null;
		}
	};

}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:11,代码来源:DependencyAnalysisTool.java

示例13: anonymousTypeFilter

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<Type,Nothing> anonymousTypeFilter(AnalysisOptions options, ObjectOrientedView view) {
	return new UniversalPredicate<Type,Nothing>(Type.class) {

		@Override
		public boolean uncheckedEval(Type type)  {
			return type.lexical().nearestAncestorOrSelf(AnonymousType.class) == null;
		}

	};
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:11,代码来源:DependencyAnalysisTool.java

示例14: annotationFilter

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<? super Type,Nothing> annotationFilter(AnalysisOptions options, ObjectOrientedView view) {
	List<String> ignoredAnnotation = ignoredAnnotationTypes((DependencyOptions) options);
	UniversalPredicate<? super Type,Nothing> filter = new True();
	for(String fqn: ignoredAnnotation) {
		try {
			Type type = view.findType(fqn);
			filter = filter.and(new NoAnnotationOfType(type)).makeUniversal(Type.class);
		} catch (LookupException e) {
		}
	}
	return filter;
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:13,代码来源:DependencyAnalysisTool.java

示例15: packageFilter

import org.aikodi.rejuse.predicate.UniversalPredicate; //导入依赖的package包/类
protected UniversalPredicate<Type,Nothing> packageFilter(final AnalysisOptions options, ObjectOrientedView view) {
	return new UniversalPredicate<Type,Nothing>(Type.class) {

		@Override
		public boolean uncheckedEval(Type type) {
			return packagePredicate(options).eval(type);
		}
	};
}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:10,代码来源:DependencyAnalysisTool.java


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