List of usage examples for com.google.common.collect Multimap isEmpty
boolean isEmpty();
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunPRP_SPO1.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subPropertyOf = AbstractDictionary.subPropertyOf; final int loops = 0; final Multimap<Long, Long> subPropertyOfMultiMap = ts1.getMultiMapForPredicate(subPropertyOf); if (subPropertyOfMultiMap != null && !subPropertyOfMultiMap.isEmpty()) { final HashMap<Long, Collection<Triple>> cachePredicates = new HashMap<>(); for (final Long p1 : subPropertyOfMultiMap.keySet()) { Collection<Triple> matchingTriples; if (!cachePredicates.containsKey(p1)) { matchingTriples = ts2.getbyPredicate(p1); cachePredicates.put(p1, matchingTriples); } else { matchingTriples = cachePredicates.get(p1); }//from www. j a v a 2 s .c o m for (final Triple triple : matchingTriples) { for (final Long p2 : subPropertyOfMultiMap.get(p1)) { final Triple result = new ImmutableTriple(triple.getSubject(), p2, triple.getObject()); outputTriples.add(result); } } } } return loops; }
From source file:org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy.java
@Override public Set<? extends NodeMetadata> listNodesByIds(Iterable<String> ids) { Multimap<String, String> idsByHandles = index(ids, splitHandle(1)); Multimap<String, String> idsByRegions = transformValues(idsByHandles, splitHandle(0)); Multimap<String, String> idsByConfiguredRegions = filterKeys(idsByRegions, in(regions.get())); if (idsByConfiguredRegions.isEmpty()) { return ImmutableSet.of(); }/*from w ww . ja va2s . c o m*/ Iterable<? extends RunningInstance> instances = pollRunningInstancesByRegionsAndIds(idsByConfiguredRegions); Iterable<? extends NodeMetadata> nodes = transform(filter(instances, notNull()), runningInstanceToNodeMetadata); return ImmutableSet.copyOf(nodes); }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunSCM_SCO.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subClassOf = AbstractDictionary.subClassOf; int loops = 0; final Multimap<Long, Long> subclassMultimap = ts1.getMultiMapForPredicate(subClassOf); if (subclassMultimap != null && !subclassMultimap.isEmpty()) { final Collection<Triple> subclassTriples = ts2.getbyPredicate(subClassOf); final HashMap<Long, Collection<Long>> cachePredicates = new HashMap<>(); /* For each type triple */ for (final Triple triple : subclassTriples) { /*/* w ww .java2 s .c om*/ * Get all objects (c1a) of subClassOf triples with */ Collection<Long> c3s; if (!cachePredicates.containsKey(triple.getObject())) { c3s = subclassMultimap.get(triple.getObject()); cachePredicates.put(triple.getObject(), c3s); } else { c3s = cachePredicates.get(triple.getObject()); } loops++; for (final Long c1a : c3s) { if (c1a != triple.getSubject() && !ts1.contains(triple.getSubject(), subClassOf, c1a) && !ts2.contains(triple.getSubject(), subClassOf, c1a)) { final Triple result = new ImmutableTriple(triple.getSubject(), subClassOf, c1a); outputTriples.add(result); } } } } return loops; }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunSCM_EQC2.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subClassOf = AbstractDictionary.subClassOf; final long equivalentClass = AbstractDictionary.equivalentClass; int loops = 0; final Multimap<Long, Long> subclassMultimap = ts1.getMultiMapForPredicate(subClassOf); if (subclassMultimap != null && !subclassMultimap.isEmpty()) { final Collection<Triple> subclassTriples = ts2.getbyPredicate(subClassOf); final HashMap<Long, Collection<Long>> cachePredicates = new HashMap<>(); /* For each type triple */ for (final Triple triple : subclassTriples) { /*/* w w w . j a v a 2 s. c om*/ * Get all objects (c1a) of subClassOf triples with */ Collection<Long> c1as; if (!cachePredicates.containsKey(triple.getObject())) { c1as = subclassMultimap.get(triple.getObject()); cachePredicates.put(triple.getObject(), c1as); } else { c1as = cachePredicates.get(triple.getObject()); } loops++; for (final Long c1a : c1as) { if (c1a == triple.getSubject() && triple.getObject() != triple.getSubject()) { final Triple result = new ImmutableTriple(triple.getSubject(), equivalentClass, triple.getObject()); outputTriples.add(result); } } } } return loops; }
From source file:org.hudsonci.plugins.vault.install.PackageSelector.java
public boolean matches(final Package pkg, final NodeContext context) { assert pkg != null; assert context != null; Multimap<String, String> props = pkg.getProperties(); // No properties, matches anything if (props.isEmpty()) { return true; }// w w w. j a v a 2 s .c o m Map<String, String> attrs = context.getAttributes(); for (String key : props.keySet()) { String found = attrs.get(key); boolean matched = false; // See if the found data, matches at least one of our properties keys for (String expect : props.get(key)) { if (expect.equalsIgnoreCase(found)) { matched = true; break; } } // If none of the values matched, we don't match if (!matched) { return false; } } // If we get this far, all property keys have matched return true; }
From source file:org.apache.brooklyn.core.mgmt.rebind.dto.AbstractMemento.java
protected <K, V> Multimap<K, V> toPersistedMultimap(Multimap<K, V> m) { if (m == null || m.isEmpty()) return null; return m;//from w ww . jav a 2 s .co m }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunSCM_SPO.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subPropertyOf = AbstractDictionary.subPropertyOf; int loops = 0; final Multimap<Long, Long> subpropertyMultimap = ts1.getMultiMapForPredicate(subPropertyOf); if (subpropertyMultimap != null && !subpropertyMultimap.isEmpty()) { final Collection<Triple> subpropertyTriples = ts2.getbyPredicate(subPropertyOf); final HashMap<Long, Collection<Long>> cachePredicates = new HashMap<>(); /* For each type triple */ for (final Triple triple : subpropertyTriples) { /*// www. j a va 2s . c om * Get all objects (p3) of subPropertyOf triples with */ Collection<Long> p3s; if (!cachePredicates.containsKey(triple.getObject())) { p3s = subpropertyMultimap.get(triple.getObject()); cachePredicates.put(triple.getObject(), p3s); } else { p3s = cachePredicates.get(triple.getObject()); } loops++; for (final Long p3 : p3s) { if (p3 != triple.getSubject()) { final Triple result = new ImmutableTriple(triple.getSubject(), subPropertyOf, p3); outputTriples.add(result); } } } } return loops; }
From source file:com.qualys.feign.jaxrs.BeanParamTransformerFactory.java
protected BeanParamTransformer createTransformer(Type beanClass, int paramIndex) { try {/*from w w w . j a v a2 s .c o m*/ List<BeanParamPropertyMetadata> propertyMetas = new ArrayList<BeanParamPropertyMetadata>(); // Find annotated write methods and their respective reads Map<String, PropertyDescriptor> descriptorsByName = new HashMap<String, PropertyDescriptor>(); BeanInfo info = Introspector.getBeanInfo((Class<?>) beanClass); for (PropertyDescriptor prop : info.getPropertyDescriptors()) { if (prop.getReadMethod() != null && prop.getWriteMethod() != null) { Multimap<String, Annotation> names = getNames(prop.getWriteMethod().getAnnotations()); if (!names.isEmpty()) { propertyMetas.add(new BeanParamPropertyMetadata(names, null, prop.getReadMethod())); } } descriptorsByName.put(prop.getName(), prop); } // Find annotated fields, prefer getter access but use field in none is found for (Field field : ReflectionUtil.getAllDeclaredFields((Class<?>) beanClass, true)) { String fieldName = field.getName(); if (descriptorsByName.containsKey(fieldName)) { PropertyDescriptor descriptor = descriptorsByName.get(fieldName); Multimap<String, Annotation> names = getNames(field.getAnnotations()); if (descriptor.getReadMethod() != null && !names.isEmpty()) { propertyMetas.add(new BeanParamPropertyMetadata(names, null, descriptor.getReadMethod())); continue; } } Multimap<String, Annotation> names = getNames(field.getAnnotations()); if (!names.isEmpty()) propertyMetas.add(new BeanParamPropertyMetadata(names, field, null)); } String[][] names = new String[propertyMetas.size()][]; Method[] getters = new Method[propertyMetas.size()]; Field[] fields = new Field[propertyMetas.size()]; Multimap<Class<?>, String> params = ArrayListMultimap.create(); for (int i = 0; i < propertyMetas.size(); i++) { BeanParamPropertyMetadata propertyMetadata = propertyMetas.get(i); fields[i] = propertyMetadata.property; getters[i] = propertyMetadata.getter; names[i] = propertyMetadata.names.keySet().toArray(new String[] {}); invertFrom(transformValues(propertyMetadata.names, v -> (Class<?>) v.getClass().getInterfaces()[0]), params); } return new BeanParamTransformer(names, ImmutableMultimap.copyOf(params), fields, getters, paramIndex); } catch (IntrospectionException e) { throw new RuntimeException(format("Unable to build bean info for %s", beanClass), e); } }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunSCM_EQP2.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subPropertyOf = AbstractDictionary.subPropertyOf; final long equivalentProperty = AbstractDictionary.equivalentProperty; int loops = 0; final Multimap<Long, Long> subpropertyMultimap = ts1.getMultiMapForPredicate(subPropertyOf); if (subpropertyMultimap != null && !subpropertyMultimap.isEmpty()) { final Collection<Triple> subpropertyTriples = ts2.getbyPredicate(subPropertyOf); final HashMap<Long, Collection<Long>> cachePredicates = new HashMap<>(); /* For each type triple */ for (final Triple triple : subpropertyTriples) { /*// ww w.ja v a 2s. c o m * Get all objects (c1a) of subPropertyOf triples with */ Collection<Long> c1as; if (!cachePredicates.containsKey(triple.getObject())) { c1as = subpropertyMultimap.get(triple.getObject()); cachePredicates.put(triple.getObject(), c1as); } else { c1as = cachePredicates.get(triple.getObject()); } loops++; for (final Long c1a : c1as) { if (c1a == triple.getSubject() && triple.getObject() != triple.getSubject()) { final Triple result = new ImmutableTriple(triple.getSubject(), equivalentProperty, triple.getObject()); outputTriples.add(result); } } } } return loops; }
From source file:gr.forth.ics.swkm.model2.index.NamespaceIndexer.java
private void removeEntry(Resource resource, RdfType type) { if (!type.isSchema()) { return;//from w w w.j av a 2s. com } Uri namespace = resource.getUri().getNamespaceUri(); Multimap<RdfType, Resource> map = index.get(namespace); if (map == null) { return; } map.remove(type, resource); if (map.isEmpty()) { index.remove(namespace); } }