List of usage examples for com.google.common.collect Multimaps filterEntries
@CheckReturnValue public static <K, V> SetMultimap<K, V> filterEntries(SetMultimap<K, V> unfiltered, Predicate<? super Entry<K, V>> entryPredicate)
From source file:org.pentaho.di.trans.dataservice.optimization.paramgen.SourceLineageMap.java
public SourceLineageMap filter(Predicate<? super Map.Entry<String, List<StepFieldOperations>>> predicate) { return new SourceLineageMap(Multimaps.filterEntries(storage, predicate)); }
From source file:net.hydromatic.optiq.jdbc.OptiqSchema.java
public OptiqSchema(OptiqSchema parent, final Schema schema) { this.parent = parent; this.schema = schema; assert (parent == null) == (this instanceof OptiqRootSchema); this.compositeTableMap = CompositeMap.of(Maps.transformValues(tableMap, new Function<TableEntry, Table>() { public Table apply(TableEntry input) { return input.getTable(); }//from ww w . j a v a2 s .c o m }), Maps.transformValues( Multimaps.filterEntries(tableFunctionMap, new Predicate<Map.Entry<String, TableFunctionEntry>>() { public boolean apply(Map.Entry<String, TableFunctionEntry> input) { return input.getValue().getTableFunction().getParameters().isEmpty(); } }).asMap(), new Function<Collection<TableFunctionEntry>, Table>() { public Table apply(Collection<TableFunctionEntry> input) { // At most one function with zero parameters. TableFunctionEntry entry = input.iterator().next(); return entry.getTableFunction().apply(ImmutableList.of()); } }), Compatible.INSTANCE.asMap(schema.getTableNames(), new Function<String, Table>() { public Table apply(String input) { return schema.getTable(input); } })); // TODO: include schema's table functions in this map. this.compositeTableFunctionMap = Multimaps.transformValues(tableFunctionMap, new Function<TableFunctionEntry, TableFunction>() { public TableFunction apply(TableFunctionEntry input) { return input.getTableFunction(); } }); this.compositeSubSchemaMap = CompositeMap.of(subSchemaMap, Compatible.INSTANCE .<String, OptiqSchema>asMap(schema.getSubSchemaNames(), new Function<String, OptiqSchema>() { public OptiqSchema apply(String input) { return addSchema(schema.getSubSchema(input)); } })); }
From source file:org.mitreid.multiparty.service.InMemoryResourceService.java
@Override public SharedResourceSet getSharedResourceSetForResource(final Resource res) { Multimap<String, Resource> filtered = Multimaps.filterEntries(resources, new Predicate<Entry<String, Resource>>() { @Override//from ww w. java 2 s . co m public boolean apply(Entry<String, Resource> input) { if (input.getValue().equals(res)) { return true; } else { return false; } } }); String principalName = Iterators.getOnlyElement(filtered.entries().iterator()).getKey(); return sharedResourceSets.get(principalName); }
From source file:com.github.x3333.dagger.aop.internal.InterceptorProcessorStep.java
@Override public Set<Element> process(final SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) { // No services registered, maybe a missing dependency? if (this.services.size() == 0) { printError(null,/*ww w .ja va2 s . co m*/ "No InterceptorHandler registered. Did you forgot to add some interceptor in your dependencies?"); return Collections.emptySet(); } final Map<ExecutableElement, MethodBind.Builder> builders = new HashMap<>(); for (final Class<? extends Annotation> annotation : this.services.keySet()) { final InterceptorHandler service = this.services.get(annotation); // Group by Method for (final Element element : elementsByAnnotation.get(annotation)) { String errorMessage = validateElement(element); if (errorMessage != null) { printError(element, errorMessage); continue; } final ExecutableElement methodElement = MoreElements.asExecutable(element); errorMessage = service.validateMethod(methodElement); if (errorMessage != null) { printError(element, errorMessage); continue; } builders.computeIfAbsent(// methodElement, // key -> MethodBind.builder().setMethodElement(methodElement))// .annotationsBuilder().add(annotation); } } // Group by Class // Tree map to order methods in the same order they appear in the source code. final Multimap<TypeElement, MethodBind> classes = TreeMultimap.create( Comparator.comparing(o -> o.getSimpleName().toString()), Comparator.comparingInt(MethodBind::getOrder)); builders.values().forEach(b -> { final MethodBind bind = b.build(); classes.put(bind.getClassElement(), bind); }); // Process binds by grouped Class final Map<TypeSpec, TypeElement> generatedTypes = new HashMap<>(); for (final TypeElement element : classes.keySet()) { final TypeSpec generatedType = processBind(element, classes.get(element)); generatedTypes.put(generatedType, element); } if (!this.disableModuleGeneration.isPresent() || !this.disableModuleGeneration.get()) { // Generate Dagger Module for intercepted Classes generateInterceptorModule(generatedTypes); } // PostProcess to Handlers for (final Entry<Class<? extends Annotation>, InterceptorHandler> serviceEntry : this.services.entrySet()) { final Multimap<TypeElement, MethodBind> bindings = Multimaps.filterEntries(classes, entry -> entry.getValue().getAnnotations().contains(serviceEntry.getKey())); serviceEntry.getValue().postProcess(this.processingEnv, bindings.keySet()); } return Collections.emptySet(); }
From source file:org.sosy_lab.cpachecker.cpa.smg.graphs.PredRelation.java
public boolean isLessOrEqual(PredRelation pPathPredicateRelation) { if (smgValuesDependency.size() > pPathPredicateRelation.smgValuesDependency.size()) { return false; }/* ww w. j ava2 s . co m*/ if (smgExplicitValueRelation.size() > pPathPredicateRelation.smgExplicitValueRelation.size()) { return false; } if (smgValuesRelation.size() > pPathPredicateRelation.smgValuesDependency.size()) { return false; } if (!Multimaps.filterEntries(smgValuesDependency, new FilterPredicate<>(pPathPredicateRelation.smgValuesDependency)).isEmpty()) { return false; } if (!Multimaps.filterEntries(smgExplicitValueRelation, new FilterPredicate<>(pPathPredicateRelation.smgExplicitValueRelation)).isEmpty()) { return false; } if (!Multimaps .filterEntries(smgValuesRelation, new FilterPredicate<>(pPathPredicateRelation.smgValuesRelation)) .isEmpty()) { return false; } return true; }
From source file:com.google.gerrit.server.notedb.ChangeNotes.java
public ImmutableListMultimap<RevId, Comment> getDraftComments(Account.Id author, @Nullable Ref ref) throws OrmException { loadDraftComments(author, ref);/*w w w . ja v a 2 s .com*/ // Filter out any zombie draft comments. These are drafts that are also in // the published map, and arise when the update to All-Users to delete them // during the publish operation failed. return ImmutableListMultimap.copyOf(Multimaps.filterEntries(draftCommentNotes.getComments(), e -> !getCommentKeys().contains(e.getValue().key))); }