List of usage examples for com.google.common.collect Sets filter
@GwtIncompatible("NavigableSet") @SuppressWarnings("unchecked") @CheckReturnValue public static <E> NavigableSet<E> filter(NavigableSet<E> unfiltered, Predicate<? super E> predicate)
From source file:org.opendaylight.groupbasedpolicy.renderer.apic.EndpointManager.java
/** * Get the set of nodes/*from ww w.j a va 2s .co m*/ * @param nodeId the nodeId of the switch to get endpoints for * @return a collection of {@link Endpoint} objects. */ public Set<NodeId> getNodesForGroup(final EgKey egKey) { return Collections.unmodifiableSet(Sets.filter(endpointsByNode.keySet(), new Predicate<NodeId>() { @Override public boolean apply(NodeId input) { Map<EgKey, Set<EpKey>> nodeEps = endpointsByNode.get(input); return (nodeEps != null && nodeEps.containsKey(egKey)); } })); }
From source file:org.locationtech.geogig.storage.memory.HeapConfigDatabase.java
private void removeSection(ConcurrentMap<String, String> config, String section) { checkNotNull(section);// w w w . j av a 2 s .com final String prefix = section + "."; Set<String> matching = new HashSet<>(Sets.filter(config.keySet(), (k) -> k.startsWith(prefix))); if (matching.isEmpty()) { throw new ConfigException(StatusCode.MISSING_SECTION); } matching.forEach((k) -> { config.remove(k); }); }
From source file:dagger.internal.codegen.DuplicateBindingsValidation.java
private String incompatibleBindingsMessage(DependencyRequest dependencyRequest, ImmutableSet<BindingNode> duplicateBindings, BindingGraph graph) { ImmutableSet<BindingNode> multibindings = duplicateBindings.stream() .filter(node -> node.binding().kind().isMultibinding()).collect(toImmutableSet()); verify(multibindings.size() == 1, "expected only one multibinding for %s: %s", dependencyRequest, multibindings);//from www. j a va 2 s . c om StringBuilder message = new StringBuilder(); java.util.Formatter messageFormatter = new java.util.Formatter(message); messageFormatter.format("%s has incompatible bindings or declarations:\n", dependencyRequest.key()); message.append(INDENT); BindingNode multibinding = getOnlyElement(multibindings); messageFormatter.format("%s bindings and declarations:", multibindingTypeString(multibinding)); formatDeclarations(message, 2, declarations(graph, multibindings)); Set<BindingNode> uniqueBindings = Sets.filter(duplicateBindings, binding -> !binding.equals(multibinding)); message.append(INDENT).append("Unique bindings and declarations:"); formatDeclarations(message, 2, Sets.filter(declarations(graph, uniqueBindings), declaration -> !(declaration instanceof MultibindingDeclaration))); return message.toString(); }
From source file:edu.harvard.med.screensaver.model.AuditedAbstractEntity.java
@Transient public SortedSet<AdministrativeActivity> getUpdateActivitiesOfType(AdministrativeActivityType activityType) { return Sets.newTreeSet(Sets.filter(_updateActivities, AdministrativeActivity.IsOfType(activityType))); }
From source file:com.griddynamics.jagger.coordinator.memory.MemoryCoordinator.java
@Override public Set<NodeId> getAvailableNodes(final NodeType type) throws CoordinatorException { return Sets.filter(nodes.keySet(), new Predicate<NodeId>() { @Override//from www. j a va 2 s . c om public boolean apply(NodeId input) { return input.getType().equals(type); } }); }
From source file:org.sosy_lab.cpachecker.util.predicates.weakening.InductiveWeakeningManager.java
/** * This method supports different states of <i>from</i> and <i>to</i> state * lemmas. Only the lemmas associated with the <i>to</i> state can be dropped. * * @param fromStateLemmas Uninstantiated lemmas associated with the * <i>from</i> state. * @param transition Transition from <i>fromState</i> to <i>toState</i>. * Has to start at {@code startingSSA}. * @param toStateLemmas Uninstantiated lemmas associated with the * <i>to</i> state. * * @return Subset of {@code toStateLemmas} to which everything in * {@code fromStateLemmas} maps./*from www . ja va 2s . co m*/ */ public Set<BooleanFormula> findInductiveWeakeningForRCNF(SSAMap startingSSA, Set<BooleanFormula> fromStateLemmas, final PathFormula transition, Set<BooleanFormula> toStateLemmas) throws SolverException, InterruptedException { // Mapping from selectors to the items they annotate. final BiMap<BooleanFormula, BooleanFormula> selectionInfo = HashBiMap.create(); List<BooleanFormula> fromStateLemmasInstantiated = fmgr.instantiate(fromStateLemmas, startingSSA); List<BooleanFormula> toStateLemmasInstantiated = fmgr.instantiate(toStateLemmas, transition.getSsa()); BooleanFormula toStateLemmasAnnotated = annotateConjunctions(toStateLemmasInstantiated, selectionInfo); final Set<BooleanFormula> toAbstract = findSelectorsToAbstract(selectionInfo, bfmgr.and(fromStateLemmasInstantiated), transition, toStateLemmasAnnotated, startingSSA, fromStateLemmas); Set<BooleanFormula> out = Sets.filter(toStateLemmas, lemma -> (!toAbstract .contains(selectionInfo.inverse().get(fmgr.instantiate(lemma, transition.getSsa()))))); assert checkAllMapsTo(fromStateLemmas, startingSSA, out, transition.getSsa(), transition.getFormula()); return out; }
From source file:org.eclipse.sirius.diagram.ui.internal.refresh.diagram.DDiagramCanonicalSynchronizer.java
private void manageCreatedViewsLayout(Set<View> createdViews) { // get view to layout "normally" Set<View> filteredCreatedViewsToLayout = Sets.filter(createdViews, new Predicate<View>() { @Override//from w w w . jav a2 s. c o m public boolean apply(View input) { return input.eAdapters().contains(SiriusLayoutDataManager.INSTANCE.getAdapterMarker()); } }); // get view to center layout Set<View> filteredCreatedViewsWithCenterLayout = Sets.filter(createdViews, new Predicate<View>() { @Override public boolean apply(View input) { return input.eAdapters().contains(SiriusLayoutDataManager.INSTANCE.getCenterAdapterMarker()); } }); Set<View> createdViewsWithCenterLayout = Sets.newLinkedHashSet(filteredCreatedViewsWithCenterLayout); Set<View> createdViewsToLayout = Sets.newLinkedHashSet(filteredCreatedViewsToLayout); // center layout must be only done on the super containers : // filter the createdViewsWithCenterLayout : only the container(s) // of all the new created views must have a center layout. // the filtered views must have a "normal" layout. calculateCenterLayout(createdViewsWithCenterLayout, createdViewsToLayout); if (!createdViewsWithCenterLayout.isEmpty() && storeViews2Arrange) { SiriusLayoutDataManager.INSTANCE.addCreatedViewWithCenterLayout(gmfDiagram, Sets.newLinkedHashSet(createdViewsWithCenterLayout)); removeAlreadyArrangeMarker(filteredCreatedViewsWithCenterLayout); } if (!createdViewsToLayout.isEmpty() && storeViews2Arrange) { SiriusLayoutDataManager.INSTANCE.addCreatedViewsToLayout(gmfDiagram, Sets.newLinkedHashSet(createdViewsToLayout)); removeAlreadyArrangeMarker(filteredCreatedViewsToLayout); } }
From source file:org.estatio.dom.asset.FixedAsset.java
public String validateNewRole(final FixedAssetRoleType type, final Party party, final LocalDate startDate, final LocalDate endDate) { if (startDate != null && endDate != null && startDate.isAfter(endDate)) { return "End date cannot be earlier than start date"; }// w w w . j a va 2s . com if (!Sets.filter(getRoles(), type.matchingRole()).isEmpty()) { return "Add a successor/predecessor from existing role"; } return null; }
From source file:com.android.builder.core.DexProcessBuilder.java
@NonNull private List<String> getFilesToAdd(@NonNull BuildToolInfo buildToolInfo) throws ProcessException { // remove non-existing files. Set<File> existingFiles = Sets.filter(mInputs, new Predicate<File>() { @Override//from w ww .j a v a 2 s .c o m public boolean apply(@Nullable File input) { return input != null && input.exists(); } }); if (existingFiles.isEmpty()) { throw new ProcessException("No files to pass to dex."); } // sort the inputs List<File> sortedList = Lists.newArrayList(existingFiles); Collections.sort(sortedList, new Comparator<File>() { @Override public int compare(File file, File file2) { boolean file2IsDir = file2.isDirectory(); if (file.isDirectory()) { return file2IsDir ? 0 : -1; } else if (file2IsDir) { return 1; } long diff = file.length() - file2.length(); return diff > 0 ? 1 : (diff < 0 ? -1 : 0); } }); // convert to String-based paths. List<String> filePathList = Lists.newArrayListWithCapacity(sortedList.size()); for (File f : sortedList) { filePathList.add(f.getAbsolutePath()); } if (mTempInputFolder != null && buildToolInfo.getRevision().compareTo(MIN_BUILD_TOOLS_REVISION_FOR_DEX_INPUT_LIST) >= 0) { File inputListFile = new File(mTempInputFolder, "inputList.txt"); // Write each library line by line to file try { Files.asCharSink(inputListFile, Charsets.UTF_8).writeLines(filePathList); } catch (IOException e) { throw new ProcessException(e); } return Collections.singletonList("--input-list=" + inputListFile.getAbsolutePath()); } else { return filePathList; } }
From source file:edu.mayo.cts2.framework.core.plugin.ExportsBuilder.java
private void enforceFrameworkVersion(Map<String, String> exportPackages) { final String frameworkVersion = PluginFrameworkUtils.getPluginFrameworkVersion(); // convert the version to OSGi format. DefaultOsgiVersionConverter converter = new DefaultOsgiVersionConverter(); final String frameworkVersionOsgi = converter.getVersion(frameworkVersion); for (String pkg : Sets.filter(exportPackages.keySet(), UNDER_PLUGIN_FRAMEWORK)) { exportPackages.put(pkg, frameworkVersionOsgi); }/*from www . j av a 2 s . c o m*/ }