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

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

Introduction

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

Prototype

public static <T> Predicate<T> in(Collection<? extends T> target) 

Source Link

Document

Returns a predicate that evaluates to true if the object reference being tested is a member of the given collection.

Usage

From source file:no.ssb.jsonstat.v2.Dataset.java

/**
 * Return the dimensions of the dataset.
 *
 * @see Dimension/*from   w ww.j a v  a 2 s.  co m*/
 * @see <a href="https://json-stat.org/format/#dimension">json-stat.org/format/#dimension</a>
 */
@JsonIgnore
public Map<String, Dimension> getDimension(Collection<String> filter) {
    if (firstNonNull(filter, Collections.emptySet()).isEmpty())
        return Collections.emptyMap();

    return Maps.filterKeys(getDimension(), Predicates.in(filter));
}

From source file:org.splevo.ui.vpexplorer.providers.VPExplorerContentProvider.java

/**
 * @param parentElement/*from w w  w  .  j  av  a 2 s .co m*/
 * @return
 */
private Object[] getChildren(VariationPointGroup parentElement) {
    VPExplorer vpexplorer = (VPExplorer) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .findView("org.splevo.ui.vpexplorer");

    VariationPointGroup group = (VariationPointGroup) parentElement;
    Collection<FileWrapper> childFiles = new LinkedList<FileWrapper>();
    if (vpexplorer.getShowGrouping()) {
        Collection<File> files = Collections2.filter(rootFiles, Predicates.in(groupFileIndex.get(group)));
        for (File file : files) {
            childFiles.add(new FileWrapper(group, file, group));
        }
        return childFiles.toArray();
    } else {
        return group.getVariationPoints().toArray();
    }
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.operation.VerticalSpaceExpansion.java

private void categorizeMessages(Set<Message> messages) {
    messagesToResize = Sets.newHashSet();
    messagesToShift = Sets.newHashSet();
    for (Message ise : Iterables.filter(messages, Predicates.not(Predicates.in(eventsToIgnore)))) {
        if (containsInsertionPoint(ise)) {
            messagesToResize.add(ise);//  w  w w  .j a v  a 2  s .  c  o  m
        } else if (isStrictlyBelowInsertionPoint(ise) || isConnectedToAMovedExecutionByASingleEnd(ise)) {
            messagesToShift.add(ise);
        }
    }
}

From source file:com.google.devtools.build.lib.rules.objc.CrosstoolCompilationSupport.java

@Override
CompilationSupport registerLinkActions(ObjcProvider objcProvider,
        J2ObjcMappingFileProvider j2ObjcMappingFileProvider, J2ObjcEntryClassProvider j2ObjcEntryClassProvider,
        ExtraLinkArgs extraLinkArgs, Iterable<Artifact> extraLinkInputs, DsymOutputType dsymOutputType)
        throws InterruptedException {
    Iterable<Artifact> prunedJ2ObjcArchives = computeAndStripPrunedJ2ObjcArchives(j2ObjcEntryClassProvider,
            j2ObjcMappingFileProvider, objcProvider);
    ImmutableList<Artifact> bazelBuiltLibraries = Iterables.isEmpty(prunedJ2ObjcArchives)
            ? objcProvider.getObjcLibraries()
            : substituteJ2ObjcPrunedLibraries(objcProvider);

    Artifact inputFileList = intermediateArtifacts.linkerObjList();
    ImmutableSet<Artifact> forceLinkArtifacts = getForceLoadArtifacts(objcProvider);

    Iterable<Artifact> objFiles = Iterables.concat(bazelBuiltLibraries, objcProvider.get(IMPORTED_LIBRARY),
            objcProvider.getCcLibraries());
    // Clang loads archives specified in filelists and also specified as -force_load twice,
    // resulting in duplicate symbol errors unless they are deduped.
    objFiles = Iterables.filter(objFiles, Predicates.not(Predicates.in(forceLinkArtifacts)));

    registerObjFilelistAction(objFiles, inputFileList);

    LinkTargetType linkType = (objcProvider.is(Flag.USES_CPP)) ? LinkTargetType.OBJCPP_EXECUTABLE
            : LinkTargetType.OBJC_EXECUTABLE;

    ObjcVariablesExtension extension = new ObjcVariablesExtension.Builder().setRuleContext(ruleContext)
            .setObjcProvider(objcProvider).setConfiguration(ruleContext.getConfiguration())
            .setIntermediateArtifacts(intermediateArtifacts).setFrameworkNames(frameworkNames(objcProvider))
            .setLibraryNames(libraryNames(objcProvider))
            .setForceLoadArtifacts(getForceLoadArtifacts(objcProvider))
            .setAttributeLinkopts(attributes.linkopts())
            .addVariableCategory(VariableCategory.EXECUTABLE_LINKING_VARIABLES).build();

    Artifact binaryToLink = getBinaryToLink();
    CppLinkAction executableLinkAction = new CppLinkActionBuilder(ruleContext, binaryToLink)
            .setMnemonic("ObjcLink").addActionInputs(bazelBuiltLibraries)
            .addActionInputs(objcProvider.getCcLibraries())
            .addTransitiveActionInputs(objcProvider.get(IMPORTED_LIBRARY))
            .addTransitiveActionInputs(objcProvider.get(STATIC_FRAMEWORK_FILE))
            .addTransitiveActionInputs(objcProvider.get(DYNAMIC_FRAMEWORK_FILE))
            .setCrosstoolInputs(CppHelper.getToolchain(ruleContext).getLink())
            .addActionInputs(prunedJ2ObjcArchives).addActionInput(inputFileList).setLinkType(linkType)
            .setLinkStaticness(LinkStaticness.FULLY_STATIC).addVariablesExtension(extension)
            .setFeatureConfiguration(getFeatureConfiguration(ruleContext)).build();
    ruleContext.registerAction(executableLinkAction);

    return this;
}

From source file:org.locationtech.geogig.porcelain.RemoveOp.java

private Map<String, NodeRef> getDeleteTrees(RevTree workTree) {

    Iterator<NodeRef> childTrees = command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_TREES)
            .setReference(workTree.getId().toString()).call();

    ImmutableMap<String, NodeRef> treesByPath = Maps.uniqueIndex(childTrees, (ref) -> ref.path());

    Set<String> requestedTrees = Sets.intersection(treesByPath.keySet(), new HashSet<>(pathsToRemove));
    Predicate<String> keyPredicate = Predicates.in(requestedTrees);
    Map<String, NodeRef> requestedTreesMap = Maps.filterKeys(treesByPath, keyPredicate);
    return requestedTreesMap;
}

From source file:de.iteratec.iteraplan.presentation.dialog.AttributeType.model.RangeValuesComponentModel.java

private List<RangeValue> getExistingRangeValues(NumberAT target, List<RangeValue> reloadEntities) {
    final Iterable<RangeValue> existingValues = Iterables.filter(target.getRangeValues(),
            Predicates.in(reloadEntities));
    return Lists.newArrayList(existingValues);
}

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

private void checkMoves() {
    for (ISequenceEvent ise : topLevelElements) {
        if (!moveIsValid(ise, true)) {
            valid = false;/*  ww w. ja  va 2 s  .  c  om*/
            eventInError.add(ise);
            // break;
        }
    }

    if (valid) {
        Iterable<ISequenceEvent> otherMovedElements = Iterables.filter(movedElements,
                Predicates.not(Predicates.in(topLevelElements)));
        for (ISequenceEvent ise : otherMovedElements) {
            if (!(ise instanceof Operand) && !moveIsValid(ise, false)) {
                valid = false;
                eventInError.add(ise);
            }
        }
    }

    for (Message resizedMsg : Iterables.concat(startReflexiveMessageToResize, endReflexiveMessageToResize)) {
        boolean currentResizeIsValid = rangeFunction.apply(resizedMsg)
                .width() >= LayoutConstants.MESSAGE_TO_SELF_BENDPOINT_VERTICAL_GAP;
        valid = valid && currentResizeIsValid;
        if (!currentResizeIsValid) {
            eventInError.add(resizedMsg);
        }
    }

    valid = valid && checkConflictesInFinalPositions() && checkTitleZonesInFinalPositions();
}

From source file:org.kaaproject.kaa.server.common.nosql.cassandra.dao.EndpointProfileCassandraDao.java

private CassandraEndpointProfile updateProfile(CassandraEndpointProfile profile) {
    LOG.debug("Updating endpoint profile with id {}", profile.getId());
    ByteBuffer epKeyHash = profile.getEndpointKeyHash();
    byte[] keyHash = getBytes(epKeyHash);
    CassandraEndpointProfile storedProfile = findByKeyHash(keyHash);
    if (storedProfile != null) {
        profile = super.save(profile);
        List<Statement> statementList = new ArrayList<>();

        Set<String> oldEndpointGroupIds = getEndpointProfilesGroupIdSet(storedProfile);
        Set<String> newEndpointGroupIds = getEndpointProfilesGroupIdSet(profile);

        Set<String> removeEndpointGroupIds = Sets.filter(oldEndpointGroupIds,
                Predicates.not(Predicates.in(newEndpointGroupIds)));

        Set<String> addEndpointGroupIds = Sets.filter(newEndpointGroupIds,
                Predicates.not(Predicates.in(oldEndpointGroupIds)));
        if (addEndpointGroupIds != null) {
            for (String id : addEndpointGroupIds) {
                statementList.add(cassandraEpByEndpointGroupIdDao
                        .getSaveQuery(new CassandraEpByEndpointGroupId(id, epKeyHash)));
            }/*from  w  w w .  j a va 2 s . c o  m*/

            if (removeEndpointGroupIds != null) {
                for (String id : removeEndpointGroupIds) {
                    statementList.add(delete().from(EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME)
                            .where(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_GROUP_ID_PROPERTY, id))
                            .and(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY, epKeyHash)));
                }
            }
            executeBatch(statementList.toArray(new Statement[statementList.size()]));
        } else {
            LOG.error("[{}] Can't update endpoint profile with version {}. "
                    + "Endpoint profile already changed!", profile.getId(), profile.getVersion());
            throw new KaaOptimisticLockingFailureException(
                    "Can't update endpoint profile with" + " version . Endpoint profile already changed!");
        }

        String accessToken = profile.getAccessToken();
        if (storedProfile.getAccessToken() != null && !storedProfile.getAccessToken().equals(accessToken)) {
            cassandraEpByAccessTokenDao.removeById(storedProfile.getAccessToken());
        }
        if (accessToken != null) {
            statementList.add(cassandraEpByAccessTokenDao
                    .getSaveQuery(new CassandraEpByAccessToken(accessToken, epKeyHash)));
        }
        executeBatch(statementList.toArray(new Statement[statementList.size()]));
        LOG.debug("[{}] Endpoint profile updated", profile.getId());
    } else {
        LOG.error("[{}] Stored profile is null. Can't update endpoint profile.", profile.getId());
        throw new DatabaseProcessingException("Stored profile is null. " + "Can't update endpoint profile.");
    }
    return profile;
}

From source file:org.eclipse.sirius.business.internal.session.danalysis.SessionResourcesTracker.java

/**
 * Check the resources in the resourceSet. Detect new resources and add them
 * to the session as new semantic resources or referenced session resources.<BR>
 * <BR>/*from   www  .  j  a  v a 2 s.c o  m*/
 * New semantic resources are :
 * <UL>
 * <LI>Resources that are not in the <code>knownResources</code> list</LI>
 * <LI>Resources that are not in the semantic resources of this session</LI>
 * <LI>Resources that are not in the referenced representations files
 * resources of this session</LI>
 * <LI>Resources that are not the Sirius environment resource</LI>
 * </UL>
 * <BR>
 * New referenced session resources are :
 * <UL>
 * <LI>Resources that are not in the <code>knownResources</code> list</LI>
 * <LI>Resources that are in the referenced representations files resources
 * of this session (the list is computed from the allAnalyses() result)</LI>
 * </UL>
 * 
 * @param knownResources
 *            List of resources that is already loaded before the resolveAll
 *            of the representations file load.
 */
static void manageAutomaticallyLoadedResources(final DAnalysisSessionImpl session,
        List<Resource> knownResources) {
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    List<Resource> resourcesAfterLoadOfSession = Lists.newArrayList(domain.getResourceSet().getResources());
    // Remove the known resources
    Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), knownResources);

    if (resourcesAfterLoadOfSession.isEmpty()) {
        return;
    }

    Set<Resource> referencedSessionResources = session.getReferencedSessionResources();
    Collection<Resource> newReferencedSessionResources = Lists.newArrayList(
            Iterables.filter(resourcesAfterLoadOfSession, Predicates.in(referencedSessionResources)));
    if (!newReferencedSessionResources.isEmpty()) {
        for (Resource newReferencedSessionResource : newReferencedSessionResources) {
            session.registerResourceInCrossReferencer(newReferencedSessionResource);
            for (DAnalysis refAnalysis : Iterables.filter(newReferencedSessionResource.getContents(),
                    DAnalysis.class)) {
                session.addAdaptersOnAnalysis(refAnalysis);
            }
        }
    }

    // Remove the known semantic resources
    Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), session.getSemanticResources());
    // Remove the known referenced representations file resources
    Iterators.removeAll(resourcesAfterLoadOfSession.iterator(), referencedSessionResources);

    final Iterable<Resource> newSemanticResourcesIterator = Iterables.filter(resourcesAfterLoadOfSession,
            new Predicate<Resource>() {
                public boolean apply(Resource resource) {
                    // Remove empty resource and the Sirius environment
                    return !resource.getContents().isEmpty()
                            && !(new URIQuery(resource.getURI()).isEnvironmentURI());
                }
            });
    if (!Iterables.isEmpty(newSemanticResourcesIterator)) {
        domain.getCommandStack().execute(new RecordingCommand(domain,
                Messages.SessionResourcesTracker_addReferencedSemanticResourcesMsg) {
            @Override
            protected void doExecute() {
                for (Resource resource : newSemanticResourcesIterator) {
                    session.addSemanticResource(resource.getURI(), new NullProgressMonitor());
                }
            }
        });
    }
}

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

private void checkOtherLifelines(ISequenceEvent eventToCheck, Collection<ISequenceEvent> eventsToIgnore) {
    Range rangeToCheck = eventToCheck.getVerticalRange();
    for (Lifeline lifeline : sequenceEventsInCreationRange.keySet()) {
        Collection<ISequenceEvent> overlap = sequenceEventsInCreationRange.get(lifeline);
        // Dot check event to shift lifeline
        if (!overlap.contains(eventToCheck)) {
            for (ISequenceEvent otherLifelineEvent : Iterables.filter(overlap,
                    Predicates.not(Predicates.in(eventsToIgnore)))) {
                Range otherRange = otherLifelineEvent.getVerticalRange();
                Range intersection = otherRange.intersection(rangeToCheck);
                if (!intersection.equals(rangeToCheck) && !intersection.equals(otherRange)
                        && !intersection.isEmpty()) {
                    valid = false;//from   w w  w .ja v a  2s. c om
                }
            }
        }
    }
}