當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。