List of usage examples for com.google.common.base Predicates in
public static <T> Predicate<T> in(Collection<? extends T> target)
From source file:info.magnolia.setup.for4_5.UpdateSecurityFilterClientCallbacksConfiguration.java
/** * Checks if the given node has other properties than those specified by the ignoredProperties parameter. *//*from w ww . j a va2 s .c o m*/ private void checkRemainingProperties(InstallContext ctx, Content source, String... ignoredProperties) { final Set<String> ignoredPropsSet = Sets.newHashSet(ignoredProperties); final Collection<NodeData> allProps = source.getNodeDataCollection(); final Iterable<String> allPropsNames = Iterables.transform(allProps, new Function<NodeData, String>() { @Override public String apply(NodeData from) { return from.getName(); } }); final Iterable<String> remaining = Iterables.filter(allPropsNames, Predicates.not(Predicates.in(ignoredPropsSet))); if (!Iterables.isEmpty(remaining)) { log.warn(source.getHandle() + " has the following unknown properties which were not copied: " + remaining); wereWeAbleToUpdateEverything = false; } }
From source file:com.google.devtools.build.lib.skyframe.TargetPatternPhaseFunction.java
/** * Interpret the command-line arguments. * * @param options the command-line arguments in structured form *///w ww . ja va 2s .c o m private static ResolvedTargets<Target> getTargetsToBuild(Environment env, TargetPatternList options) throws InterruptedException { List<SkyKey> patternSkyKeys = new ArrayList<>(); for (TargetPatternSkyKeyOrException keyOrException : TargetPatternValue.keys(options.getTargetPatterns(), FilteringPolicies.FILTER_MANUAL, options.getOffset())) { try { patternSkyKeys.add(keyOrException.getSkyKey()); } catch (TargetParsingException e) { // Skip. } } Map<SkyKey, ValueOrException<TargetParsingException>> resolvedPatterns = env .getValuesOrThrow(patternSkyKeys, TargetParsingException.class); if (env.valuesMissing()) { return null; } ResolvedTargets.Builder<Target> builder = ResolvedTargets.builder(); for (SkyKey key : patternSkyKeys) { TargetPatternKey pattern = (TargetPatternKey) key.argument(); TargetPatternValue value; try { value = (TargetPatternValue) resolvedPatterns.get(key).get(); } catch (TargetParsingException e) { // TODO(ulfjack): Report to EventBus. String rawPattern = pattern.getPattern(); String errorMessage = e.getMessage(); env.getListener().handle(Event.error("Skipping '" + rawPattern + "': " + errorMessage)); builder.setError(); continue; } // TODO(ulfjack): This is terribly inefficient. ResolvedTargets<Target> asTargets = TestSuiteExpansionFunction.labelsToTargets(env, value.getTargets().getTargets(), value.getTargets().hasError()); if (pattern.isNegative()) { builder.filter(Predicates.not(Predicates.in(asTargets.getTargets()))); } else { builder.merge(asTargets); } } ResolvedTargets<Target> result = builder.filter(TargetUtils.tagFilter(options.getBuildTargetFilter())) .build(); if (options.getCompileOneDependency()) { TargetProvider targetProvider = new EnvironmentBackedRecursivePackageProvider(env); try { return new CompileOneDependencyTransformer(targetProvider) .transformCompileOneDependency(env.getListener(), result); } catch (MissingDepException e) { return null; } catch (TargetParsingException e) { env.getListener().handle(Event.error(e.getMessage())); return ResolvedTargets.failed(); } } return result; }
From source file:org.apache.cassandra.io.sstable.SSTable.java
/** * Registers new custom components. Used by custom compaction strategies. * Adding a component for the second time is a no-op. * Don't remove this - this method is a part of the public API, intended for use by custom compaction strategies. * @param newComponents collection of components to be added *///from w w w . ja v a2 s.c om public synchronized void addComponents(Collection<Component> newComponents) { Collection<Component> componentsToAdd = Collections2.filter(newComponents, Predicates.not(Predicates.in(components))); appendTOC(descriptor, componentsToAdd); components.addAll(componentsToAdd); }
From source file:org.sosy_lab.cpachecker.cpa.arg.counterexamples.CEXExporter.java
private void exportCounterexample(final ARGState lastState, final int cexIndex, @Nullable final CounterexampleInfo counterexample, @Nonnull final ARGPath targetPath, final Predicate<Pair<ARGState, ARGState>> isTargetPathEdge) { final ARGState rootState = targetPath.getFirstState(); writeErrorPathFile(errorPathFile, cexIndex, createErrorPathWithVariableAssignmentInformation(targetPath.getInnerEdges(), counterexample)); if (errorPathCoreFile != null) { // the shrinked errorPath only includes the nodes, // that are important for the error, it is not a complete path, // only some nodes of the targetPath are part of it ErrorPathShrinker pathShrinker = new ErrorPathShrinker(); List<CFAEdge> shrinkedErrorPath = pathShrinker.shrinkErrorPath(targetPath); writeErrorPathFile(errorPathCoreFile, cexIndex, createErrorPathWithVariableAssignmentInformation(shrinkedErrorPath, counterexample)); }// www.j a va2s. c o m writeErrorPathFile(errorPathJson, cexIndex, new Appender() { @Override public void appendTo(Appendable pAppendable) throws IOException { if (counterexample != null && counterexample.getTargetPathModel() != null && counterexample.getTargetPathModel().getCFAPathWithAssignments() != null) { counterexample.getTargetPathModel().getCFAPathWithAssignments().toJSON(pAppendable, targetPath); } else { targetPath.toJSON(pAppendable); } } }); final Set<ARGState> pathElements; Appender pathProgram = null; if (counterexample != null && counterexample.getTargetPath() != null) { // precise error path pathElements = targetPath.getStateSet(); if (errorPathSourceFile != null) { pathProgram = PathToCTranslator.translateSinglePath(targetPath); } } else { // Imprecise error path. // For the text export, we have no other chance, // but for the C code and graph export we use all existing paths // to avoid this problem. pathElements = ARGUtils.getAllStatesOnPathsTo(lastState); if (errorPathSourceFile != null) { pathProgram = PathToCTranslator.translatePaths(rootState, pathElements); } } if (pathProgram != null) { writeErrorPathFile(errorPathSourceFile, cexIndex, pathProgram); } writeErrorPathFile(errorPathGraphFile, cexIndex, new Appender() { @Override public void appendTo(Appendable pAppendable) throws IOException { ARGToDotWriter.write(pAppendable, rootState, ARGUtils.CHILDREN_OF_STATE, Predicates.in(pathElements), isTargetPathEdge); } }); writeErrorPathFile(errorPathAutomatonFile, cexIndex, new Appender() { @Override public void appendTo(Appendable pAppendable) throws IOException { ARGUtils.producePathAutomaton(pAppendable, rootState, pathElements, "ErrorPath" + cexIndex, counterexample); } }); if (counterexample != null) { if (counterexample.getTargetPathModel() != null) { writeErrorPathFile(errorPathAssignment, cexIndex, counterexample.getTargetPathModel()); } for (Pair<Object, PathTemplate> info : counterexample.getAllFurtherInformation()) { if (info.getSecond() != null) { writeErrorPathFile(info.getSecond(), cexIndex, info.getFirst()); } } } writeErrorPathFile(errorPathAutomatonGraphmlFile, cexIndex, new Appender() { @Override public void appendTo(Appendable pAppendable) throws IOException { witnessExporter.writePath(pAppendable, rootState, ARGUtils.CHILDREN_OF_STATE, Predicates.in(pathElements), isTargetPathEdge, counterexample); } }); }
From source file:eu.numberfour.n4js.external.EclipseExternalLibraryWorkspace.java
@Override public void storeUpdated(final ExternalLibraryPreferenceStore store, final IProgressMonitor monitor) { final Set<java.net.URI> oldLocations = newLinkedHashSet(locations); final Set<java.net.URI> newLocation = newLinkedHashSet(store.getLocations()); final Collection<java.net.URI> removedLocations = difference(oldLocations, newLocation); final Collection<java.net.URI> addedLocations = difference(newLocation, oldLocations); final SubMonitor subMonitor = convert(monitor, 3); final Iterable<IProject> projectsToClean = getProjects(removedLocations); final Collection<IProject> workspaceProjectsToRebuild = newHashSet( collector.collectProjectsWithDirectExternalDependencies(projectsToClean)); // Clean projects. if (!Iterables.isEmpty(projectsToClean)) { builderHelper.clean(projectsToClean, subMonitor.newChild(1)); }/*from w w w . jav a 2s. co m*/ subMonitor.worked(1); // Update internal state. locations.clear(); locations.addAll(store.getLocations()); updateState(); // Rebuild whole external workspace. Filter out projects that are present in the Eclipse workspace (if any). final Collection<String> eclipseWorkspaceProjectNames = getAllEclipseWorkspaceProjectNames(); final Predicate<String> eclipseWorkspaceProjectNamesFilter = Predicates.in(eclipseWorkspaceProjectNames); final Iterable<IProject> projectsToBuild = from(getProjects(addedLocations)) .filter(p -> !eclipseWorkspaceProjectNamesFilter.apply(p.getName())); // Build recently added projects that do not exist in workspace. // XXX akitta: consider filtering out external projects that exists in index already. (@ higher priority level) if (!Iterables.isEmpty(projectsToBuild)) { builderHelper.build(projectsToBuild, subMonitor.newChild(1)); } subMonitor.worked(1); addAll(workspaceProjectsToRebuild, collector.collectProjectsWithDirectExternalDependencies(projectsToBuild)); scheduler.scheduleBuildIfNecessary(workspaceProjectsToRebuild); }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.operation.SynchronizeISequenceEventsSemanticOrderingOperation.java
private List<EventEnd> getCompoundEnds(ISequenceEvent eventToUpdate, List<EventEnd> ends) { List<ISequenceEvent> compoundEvents = EventEndHelper.getCompoundEvents(eventToUpdate); Predicate<ISequenceEvent> isLogicallyInstantaneousNonReorderedEvent = new Predicate<ISequenceEvent>() { @Override//from ww w . jav a 2s .c o m public boolean apply(ISequenceEvent input) { return input.isLogicallyInstantaneous() && !reordered.contains(input); }; }; Iterable<ISequenceEvent> compoundEventsToReorder = Iterables.filter(compoundEvents, isLogicallyInstantaneousNonReorderedEvent); Iterable<EventEnd> nonReorderedEndsOfCompoundEvents = Iterables .concat(Iterables.transform(compoundEventsToReorder, EventEndHelper.EVENT_ENDS)); Predicate<EventEnd> isCompoundEnd = Predicates.and(Predicates.instanceOf(SingleEventEnd.class), Predicates.not(Predicates.in(ends))); return Lists.newArrayList(Iterables.filter(nonReorderedEndsOfCompoundEvents, isCompoundEnd)); }
From source file:org.jetbrains.jet.lang.types.lang.KotlinBuiltIns.java
@NotNull private ResolveSession createLazyResolveSession(@NotNull Project project) throws IOException { List<JetFile> files = loadResourcesAsJetFiles(project, LIBRARY_FILES); return new ResolveSession(project, builtInsModule, new SpecialModuleConfiguration(project), new FileBasedDeclarationProviderFactory(files), new Function<FqName, Name>() { @Override/* www . j av a2 s .c om*/ public Name fun(FqName name) { return ALIASES.get(name); } }, Predicates.in(Sets.newHashSet(new FqNameUnsafe("jet.Any"), new FqNameUnsafe("jet.Nothing")))); }
From source file:co.cask.tigon.internal.app.runtime.distributed.AbstractProgramTwillRunnable.java
/** * Creates program arguments. It includes all configurations from the specification, excluding hConf and cConf. *//*from ww w.j a v a 2 s .c o m*/ private Arguments createProgramArguments(TwillContext context, Map<String, String> configs) { Map<String, String> args = ImmutableMap.<String, String>builder() .put(ProgramOptionConstants.INSTANCE_ID, Integer.toString(context.getInstanceId())) .put(ProgramOptionConstants.INSTANCES, Integer.toString(context.getInstanceCount())) .put(ProgramOptionConstants.RUN_ID, context.getApplicationRunId().getId()) .putAll(Maps.filterKeys(configs, Predicates.not(Predicates.in(ImmutableSet.of("hConf", "cConf"))))) .build(); return new BasicArguments(args); }
From source file:com.isotrol.impe3.pms.core.impl.EditionsServiceImpl.java
@Transactional(rollbackFor = Throwable.class) @Authorized(global = GlobalAuthority.EDITION_PUBLISH, portal = PortalAuthority.PUBLISH) public boolean publishPortal(String portalId, boolean tryParents) throws PMSException { final EnvironmentEntity env = getEnvironment(); final EditionEntity current = env.getCurrent(); final ContextGlobal ctx = loadContextGlobal(); final PortalsObject portals = loadContextGlobal().getPortals(); // Check global elements if (current == null || needs(ctx.getContentTypes().values()) || needs(ctx.getCategories().values()) || needs(ctx.getConnectors().values())) { throw new ModifiedGlobalsException(); }//from www. ja v a 2s. co m final PortalObject portal = portals.load(portalId); // Check parents final LinkedList<PortalObject> parents = Lists.newLinkedList(); PortalObject parent = portals.getParent(portal.getId()); while (parent != null) { parents.addFirst(parent); parent = portals.getParent(parent.getId()); } final boolean anyParentModified = needs(parents); final boolean portalModified = NEEDS_PUBLISHING.apply(portal.getState()); if (!anyParentModified) { if (!portalModified) { return false; } } else if (!tryParents) { throw new ModifiedParentPortalsException(); } // Prepare the set of portals to export final Set<UUID> ids; if (!anyParentModified) { ids = ImmutableSet.of(portal.getId()); } else { ids = Sets.newHashSet(); for (PortalObject p : parents) { if (!ids.isEmpty() || NEEDS_PUBLISHING.apply(p.getState())) { ids.add(p.getId()); } } ids.add(portal.getId()); } // Create edition. createEdition(env, Predicates.in(ids)); return true; }
From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.policy.ISEComplexMoveCommandBuilder.java
private void computeReparents(Collection<ISequenceNode> sequenceNodesToMove, Map<AbstractNodeEvent, ISequenceEvent> reparents) { // reparent directly moved execution Collection<AbstractNodeEvent> movedExecutions = Lists .newArrayList(Iterables.filter(sequenceNodesToMove, AbstractNodeEvent.class)); // reparent unmoved executions Collection<AbstractNodeEvent> unmovedExecutions = Lists .newArrayList(Iterables.filter(validator.getDiagram().getAllAbstractNodeEvents(), Predicates.not(Predicates.in(validator.getMovedElements())))); for (AbstractNodeEvent execToReparent : Iterables.concat(movedExecutions, unmovedExecutions)) { ISequenceEvent potentialParent = getNewParent(execToReparent, reparents); if (potentialParent instanceof ISequenceNode && !potentialParent.equals(execToReparent.getHierarchicalParentEvent())) { reparents.put(execToReparent, potentialParent); sequenceNodesToMove.remove(execToReparent); }/* ww w .j a va2 s . c o m*/ } }