List of usage examples for com.google.common.base Predicates instanceOf
@GwtIncompatible("Class.isInstance") public static Predicate<Object> instanceOf(Class<?> clazz)
From source file:com.google.devtools.build.lib.skyframe.SkyframeExecutor.java
@SuppressWarnings({ "unchecked", "rawtypes" }) Map<SkyKey, ActionLookupValue> getActionLookupValueMap() { return (Map) Maps.filterValues(memoizingEvaluator.getDoneValues(), Predicates.instanceOf(ActionLookupValue.class)); }
From source file:org.sosy_lab.cpachecker.core.algorithm.BMCAlgorithm.java
/** * Excludes the given edges from the given precision if the EdgeExclusionCPA * is activated to allow for such edge exclusions. * * @param pPrecision the precision to exclude the edges from. * @param pEdgesToIgnore the edges to be excluded. * @return the new precision.//from ww w . j a v a 2 s .c o m */ private Precision excludeEdges(Precision pPrecision, Iterable<CFAEdge> pEdgesToIgnore) { EdgeExclusionPrecision oldPrecision = Precisions.extractPrecisionByType(pPrecision, EdgeExclusionPrecision.class); if (oldPrecision != null) { EdgeExclusionPrecision newPrecision = oldPrecision.excludeMoreEdges(pEdgesToIgnore); return Precisions.replaceByType(pPrecision, newPrecision, Predicates.instanceOf(EdgeExclusionPrecision.class)); } return pPrecision; }
From source file:org.obeonetwork.dsl.uml2.design.services.UMLServices.java
/** * Get all the packageable elements available in the semantic resources. * /*from ww w .ja v a2s . com*/ * @param eObj * Semantic element * @return All the packageable elements */ public List<EObject> getAllPackageableElements(Element element) { List<EObject> result = Lists.newArrayList(); UMLServices umlServices = new UMLServices(); List<org.eclipse.uml2.uml.Package> rootPkgs = umlServices.getAllAvailableRootPackages(element); result.addAll(rootPkgs); for (org.eclipse.uml2.uml.Package pkg : rootPkgs) { Iterators.addAll(result, Iterators.filter(pkg.eAllContents(), Predicates.instanceOf(PackageableElement.class))); } if (element instanceof Package) { result.removeAll(((Package) element).getPackagedElements()); } return result; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.BorderItemAwareLayoutProvider.java
/** * Return the x axis coordinate of the right size of the rightmost child * (after the arrange all).//from w ww.j a v a 2s .c om * * @param part * The parent * @param scale * The current scale of the diagram * @param moveDelta * The parent move delta if it is know, null otherwise * @param launchNormalArrange * Tell if the normal arrange process will be called before the * border item arrange * @return the x axis coordinate of the right size of the rightmost child */ private int getRightSizeXCoordinateOfRightMostChild(final IGraphicalEditPart part, final double scale, final Dimension moveDelta) { int result = 0; final Collection<IGraphicalEditPart> children = Collections2.filter(part.getChildren(), Predicates.and(Predicates.instanceOf(IGraphicalEditPart.class), Predicates.not(Predicates.instanceOf(AbstractDiagramBorderNodeEditPart.class)), Predicates.not(Predicates.instanceOf(AbstractDiagramNameEditPart.class)))); for (IGraphicalEditPart child : children) { if (child instanceof ShapeCompartmentEditPart) { // Only delegates to the grandchildren final Collection<IGraphicalEditPart> grandchildren = Collections2.filter(child.getChildren(), Predicates.and(Predicates.instanceOf(IGraphicalEditPart.class), Predicates.not(Predicates.instanceOf(AbstractDiagramBorderNodeEditPart.class)), Predicates.not(Predicates.instanceOf(AbstractDiagramNameEditPart.class)))); for (IGraphicalEditPart grandchild : grandchildren) { final Rectangle bounds = getBounds(grandchild, scale, moveDelta, true, false); final int rightSizeXCoordinate = bounds.x + bounds.width; if (result < rightSizeXCoordinate) { result = rightSizeXCoordinate; } } } else { final Rectangle bounds = getBounds(child, scale, moveDelta, true, false); final int rightSizeXCoordinate = bounds.x + bounds.width; if (result < rightSizeXCoordinate) { result = rightSizeXCoordinate; } } } return result; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.layout.provider.BorderItemAwareLayoutProvider.java
/** * Return the y axis coordinate of the bottom size of the lowest child * (after the arrange all)./* w w w.j a v a 2 s. com*/ * * @param part * The parent * @param scale * The current scale of the diagram * @param moveDelta * The parent move delta if it is know, null otherwise * @return the y axis coordinate of the bottom size of the lowest child */ private int getBottomSizeYCoordinateOfLowestChild(final IGraphicalEditPart part, final double scale, final Dimension moveDelta) { int result = 0; final Collection<IGraphicalEditPart> children = Collections2.filter(part.getChildren(), Predicates.and(Predicates.instanceOf(IGraphicalEditPart.class), Predicates.not(Predicates.instanceOf(AbstractDiagramBorderNodeEditPart.class)), Predicates.not(Predicates.instanceOf(AbstractDiagramNameEditPart.class)))); for (IGraphicalEditPart child : children) { if (child instanceof ShapeCompartmentEditPart) { // Only delegates to the grandchildren final Collection<IGraphicalEditPart> grandchildren = Collections2.filter(child.getChildren(), Predicates.and(Predicates.instanceOf(IGraphicalEditPart.class), Predicates.not(Predicates.instanceOf(AbstractDiagramBorderNodeEditPart.class)), Predicates.not(Predicates.instanceOf(AbstractDiagramNameEditPart.class)))); for (IGraphicalEditPart grandchild : grandchildren) { final Rectangle bounds = getBounds(grandchild, scale, moveDelta, false, true); final int bottomSizeYCoordinate = bounds.y + bounds.height; if (result < bottomSizeYCoordinate) { result = bottomSizeYCoordinate; } } } else { final Rectangle bounds = getBounds(child); final int bottomSizeYCoordinate = bounds.y + bounds.height; if (result < bottomSizeYCoordinate) { result = bottomSizeYCoordinate; } } } return result; }
From source file:com.cloudera.impala.analysis.Analyzer.java
/** * Returns true if 'p' evaluates to true when all its referenced slots are NULL, * false otherwise./* w w w. j a v a 2s .c o m*/ * TODO: Can we avoid dealing with the exceptions thrown by analysis and eval? */ private boolean isTrueWithNullSlots(Expr p) { // Construct predicate with all SlotRefs substituted by NullLiterals. List<SlotRef> slotRefs = Lists.newArrayList(); p.collect(Predicates.instanceOf(SlotRef.class), slotRefs); Expr nullTuplePred = null; // Map for substituting SlotRefs with NullLiterals. ExprSubstitutionMap nullSmap = new ExprSubstitutionMap(); NullLiteral nullLiteral = new NullLiteral(); nullLiteral.analyzeNoThrow(this); for (SlotRef slotRef : slotRefs) { nullSmap.put(slotRef.clone(), nullLiteral.clone()); } nullTuplePred = p.substitute(nullSmap, this, false); try { return FeSupport.EvalPredicate(nullTuplePred, getQueryCtx()); } catch (InternalException e) { Preconditions.checkState(false, "Failed to evaluate generated predicate: " + nullTuplePred.toSql() + "." + e.getMessage()); } return true; }
From source file:org.apache.impala.analysis.Analyzer.java
/** * Returns true if 'p' evaluates to true when all its referenced slots are NULL, * false otherwise.// www .ja v a 2 s . c om * TODO: Can we avoid dealing with the exceptions thrown by analysis and eval? */ public boolean isTrueWithNullSlots(Expr p) { // Construct predicate with all SlotRefs substituted by NullLiterals. List<SlotRef> slotRefs = Lists.newArrayList(); p.collect(Predicates.instanceOf(SlotRef.class), slotRefs); // Map for substituting SlotRefs with NullLiterals. ExprSubstitutionMap nullSmap = new ExprSubstitutionMap(); for (SlotRef slotRef : slotRefs) { // Preserve the original SlotRef type to ensure all substituted // subexpressions in the predicate have the same return type and // function signature as in the original predicate. nullSmap.put(slotRef.clone(), NullLiteral.create(slotRef.getType())); } Expr nullTuplePred = p.substitute(nullSmap, this, false); try { return FeSupport.EvalPredicate(nullTuplePred, getQueryCtx()); } catch (InternalException e) { Preconditions.checkState(false, "Failed to evaluate generated predicate: " + nullTuplePred.toSql() + "." + e.getMessage()); } return true; }