Example usage for com.google.common.base Predicates instanceOf

List of usage examples for com.google.common.base Predicates instanceOf

Introduction

In this page you can find the example usage for com.google.common.base Predicates instanceOf.

Prototype

@GwtIncompatible("Class.isInstance")
public static Predicate<Object> instanceOf(Class<?> clazz) 

Source Link

Document

Returns a predicate that evaluates to true if the object being tested is an instance of the given class.

Usage

From source file:org.openhab.model.rule.scoping.RulesScopeProvider.java

private boolean containsItemTrigger(Rule rule) {
    return Iterables.any(rule.getEventtrigger(), Predicates.instanceOf(ItemEventTrigger.class));
}

From source file:com.vmware.appfactory.taskqueue.tasks.TaskRecorder.java

@SuppressWarnings("unchecked")
private <T extends TaskState> Iterable<T> findTasksForRecord(String taskType, long recordId,
        @Nonnull Class<T> klass) {
    String recordHandle = TaskFactory.makeRecordId(taskType, recordId);
    return ImmutableList.copyOf((Iterable<T>) Iterables.filter(
            Collections.unmodifiableCollection(
                    Collections2.transform(mapTaskHandleToTasks.get(recordHandle), fnGetCurrentState)),
            Predicates.instanceOf(klass)));
}

From source file:org.eclipse.sirius.table.business.internal.dialect.TableContributionsFinder.java

private Set<EObject> getAllRepresentations(Iterable<EObject> from) {
    Set<EObject> result = Sets.newHashSet();
    for (EObject eObject : from) {
        Iterables.addAll(result,/*ww  w  . j  a  va 2  s  .c o  m*/
                Iterables.filter(AllContents.of(eObject, true),
                        Predicates.or(Predicates.instanceOf(RepresentationDescription.class),
                                Predicates.instanceOf(RepresentationExtensionDescription.class))));
    }
    return result;
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.util.EditPartQuery.java

/**
 * Return the list of {@link BorderItemEditPart}s that are on the expected
 * side.//from w  ww . j a v a2 s . c o  m
 * 
 * @param expectedSide
 *            The side ({@link org.eclipse.draw2d.PositionConstants}) where
 *            the children must be
 * @return the list of {@link BorderItemEditPart}s that are on the expected
 *         side.
 */
public List<IBorderItemEditPart> getBorderNodeEditParts(final int expectedSide) {
    if (part instanceof IBorderedShapeEditPart) {
        Iterable<IBorderItemEditPart> bordersItemPart = Iterables.filter(part.getChildren(), Predicates
                .and(Predicates.instanceOf(IBorderItemEditPart.class), new Predicate<IBorderItemEditPart>() {
                    @Override
                    public boolean apply(IBorderItemEditPart input) {
                        int currentSide = input.getBorderItemLocator().getCurrentSideOfParent();
                        return expectedSide == currentSide;
                    }
                }));
        return Lists.newArrayList(bordersItemPart);
    }
    return new ArrayList<IBorderItemEditPart>();
}

From source file:edu.buaa.satla.analysis.util.CFATraversal.java

/**
 * Returns a new instance of this class which behaves exactly like the current
 * instance, except it ignores function call and return edges.
 * It will not call the visitor for them, and it will not follow this edge
 * during traversing. Thus it will always stay inside the current function.
 *//*from  w ww  .j  a  v  a2 s  . c o  m*/
@SuppressWarnings("unchecked")
public CFATraversal ignoreFunctionCalls() {
    return new CFATraversal(edgeSupplier, successorSupplier, Predicates.<CFAEdge>or(ignoreEdge,
            Predicates.instanceOf(FunctionCallEdge.class), Predicates.instanceOf(FunctionReturnEdge.class)));
}

From source file:org.eclipselabs.agrum.services.model.plugin.parser.ModelParser.java

/**
 * To get an iterator on each pseudostate of the state machine
 * @param s the state machine//from  ww  w. ja  v  a  2 s .  c  o  m
 * @return the iterator
 */
private static Iterator<Pseudostate> pseudostateIterator(StateMachine s) {
    Predicate<Object> allPseudostates = Predicates.instanceOf(Pseudostate.class);
    Iterator<EObject> result = Iterators.filter(s.eAllContents(), allPseudostates);
    Iterator<Pseudostate> pseudostates = Iterators.transform(result,
            new com.google.common.base.Function<EObject, Pseudostate>() {
                @Override
                public Pseudostate apply(EObject arg0) {
                    return (Pseudostate) arg0;
                }
            });
    return pseudostates;
}

From source file:eu.stratosphere.sopremo.expressions.EvaluationExpression.java

/**
 * Removes all sub-trees in-place that start with the given expression type.<br>
 * If expressions cannot be completely removed, they are replaced by {@link EvaluationExpression#VALUE}.
 * //from w w  w .j  av a  2s  . c o  m
 * @param expressionType
 *        the expression type to remove
 * @return this expression without removed sub-expressions
 */
public EvaluationExpression remove(final Class<?> expressionType) {
    return this.remove(Predicates.instanceOf(expressionType));
}

From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.AbstractInteractionFrameValidator.java

/**
 * Performs all the computations required to validate the resizing, and
 * stores any important information which will be useful to actually execute
 * the resize if it is valid, like for example avoid contact with siblings.
 *///  ww  w . j a  v a2 s .  c  om
protected void validate() {
    valid = checkAndComputeRanges();
    if (valid) {
        Collection<ISequenceEvent> finalParents = getFinalParentsWithAutoExpand();

        Collection<ISequenceEvent> movableParents = Lists
                .newArrayList(Iterables.filter(finalParents, Predicates.not(unMove)));
        Collection<ISequenceEvent> fixedParents = Lists.newArrayList(Iterables.filter(finalParents, unMove));
        if (movableParents.isEmpty() || !movedElements.containsAll(movableParents)) {

            valid = valid && Iterables.isEmpty(Iterables.filter(finalParents, invalidParents));
            valid = valid && (!Iterables.any(finalParents, Predicates.instanceOf(Operand.class))
                    || finalParents.size() == 1);
            valid = valid && checkFinalRangeStrictlyIncludedInParents(movableParents);
            valid = valid && checkLocalSiblings(movableParents);
        }
        valid = valid && checkFinalRangeStrictlyIncludedInParents(fixedParents);
        valid = valid && checkLocalSiblings(fixedParents);
    }

    if (getRequestQuery().isResize()) {
        valid = valid && checkGlobalPositions();
    }
}

From source file:org.sosy_lab.cpachecker.cpa.value.symbolic.refiner.ARGTreePrecisionUpdater.java

private ConstraintsPrecision extractConstraintsPrecision(final ARGReachedSet pReached, final ARGState pState) {
    return (ConstraintsPrecision) Precisions.asIterable(pReached.asReachedSet().getPrecision(pState))
            .filter(Predicates.instanceOf(ConstraintsPrecision.class)).get(0);
}

From source file:org.obm.sync.calendar.Event.java

public Collection<Attendee> getUserAttendees() {
    return Collections2.filter(attendees, Predicates.instanceOf(UserAttendee.class));
}