List of usage examples for com.google.common.collect Multimap containsKey
boolean containsKey(@Nullable Object key);
From source file:org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionProvider.java
@Override public Iterable<IEObjectDescription> getEObjectDescriptions(Resource resource) { Multimap<EObject, IEObjectDescription> map = HashMultimap.create(); IResourceDescription description = resourceDescriptionManager.getResourceDescription(resource); for (IEObjectDescription desc : description.getExportedObjects()) { EObject object = EcoreUtil.resolve(desc.getEObjectOrProxy(), resource); map.put(object, desc);/*from w ww . jav a 2 s. c o m*/ } if (!resource.getContents().isEmpty()) { TreeIterator<EObject> it = EcoreUtil2.eAll(resource.getContents().get(0)); while (it.hasNext()) { EObject next = it.next(); if (map.containsKey(next)) { continue; } QualifiedName name = qualifiedNameProvider.getFullyQualifiedName(next); if (name != null) { IEObjectDescription desc = EObjectDescription.create(name, next); map.put(next, desc); } } } List<IEObjectDescription> result = Lists.newArrayList(); for (Map.Entry<EObject, IEObjectDescription> entry : map.entries()) { QualifiedName name = computeSimpleName(map, entry.getValue()); SimpleNameDescription copy = new SimpleNameDescription(name, entry.getKey(), entry.getValue()); result.add(copy); } return result; }
From source file:io.redlink.sdk.impl.analysis.model.RDFStructureParser.java
private void setTextAnnotationData(TextAnnotation textAnnotation, BindingSet result, Multimap<Enhancement, String> relations) throws RepositoryException { if (!relations.containsKey(textAnnotation)) { setEnhancementData(textAnnotation, result); if (result.hasBinding("start")) { textAnnotation.setStarts(Integer.parseInt(result.getBinding("start").getValue().stringValue())); textAnnotation.setEnds(Integer.parseInt(result.getBinding("end").getValue().stringValue())); }//from w w w.j av a 2 s . c o m if (result.hasBinding("relation")) { String nextRelationUri = result.getBinding("relation").getValue().stringValue(); relations.put(textAnnotation, nextRelationUri); } if (result.hasBinding("selectionContext")) { textAnnotation.setSelectionContext(result.getBinding("selectionContext").getValue().stringValue()); } if (result.hasBinding("selectedText")) { Binding selectedText = result.getBinding("selectedText"); textAnnotation.setSelectedText(selectedText.getValue().stringValue()); if (!result.hasBinding("language") && (selectedText.getValue() instanceof Literal)) textAnnotation.setLanguage(((Literal) selectedText.getValue()).getLanguage()); } if (result.hasBinding("type")) { Binding type = result.getBinding("type"); textAnnotation.setType(type.getValue().stringValue()); } } else { if (result.hasBinding("relation")) { String nextRelationUri = result.getBinding("relation").getValue().stringValue(); relations.put(textAnnotation, nextRelationUri); } } }
From source file:org.eclipse.xtext.xbase.typesystem.override.RawResolvedFeatures.java
protected void computeAllFeatures(JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations, Set<String> processedFields, ListMultimap<String, JvmFeature> result, Set<String> seenNames) { Iterable<JvmFeature> features = type.getAllFeatures(); for (JvmFeature feature : features) { if (!seenNames.contains(feature.getSimpleName())) { if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (isOverridden(operation, processedOperations.get(simpleName))) { continue; }//from w w w . ja v a 2 s . co m } BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(simpleName, resolvedOperation); result.put(simpleName, operation); } else if (feature instanceof JvmField && processedFields.add(feature.getSimpleName())) { result.put(feature.getSimpleName(), feature); } } } }
From source file:org.ow2.proactive.scheduler.authentication.ManageUsers.java
/** * Update the accounts in the login and config files * * @throws ManageUsersException/* w w w .j a v a 2 s .c om*/ */ private static void updateAccounts(final PublicKey pubKey, final UserInfo userInfo, final String loginFilePath, final String groupFilePath, final Action action, final String sourceLoginFile, final String sourceGroupFile) throws ManageUsersException { try { Properties destinationLoginProps = new Properties(); try (InputStreamReader stream = new InputStreamReader(new FileInputStream(loginFilePath))) { destinationLoginProps.load(stream); } catch (Exception e) { exitWithErrorMessage("could not read login file : " + loginFilePath, null, e); } Multimap<String, String> destinationGroupsMap = loadGroups(groupFilePath); Properties sourceLoginProps = new Properties(); if (sourceLoginFile != null) { try (InputStreamReader stream = new InputStreamReader(new FileInputStream(sourceLoginFile))) { sourceLoginProps.load(stream); } catch (Exception e) { exitWithErrorMessage("could not read source login file : " + sourceLoginFile, null, e); } } else if (userInfo != null) { if (userInfo.getPassword() == null) { // password can be null in case of account deletion sourceLoginProps.put(userInfo.getLogin(), ""); } else { sourceLoginProps.put(userInfo.getLogin(), userInfo.getPassword()); } } Multimap<String, String> sourceGroupsMap = null; if (sourceGroupFile != null) { sourceGroupsMap = loadGroups(sourceGroupFile); } else { sourceGroupsMap = TreeMultimap.create(); if (userInfo != null && !userInfo.getGroups().isEmpty()) { for (String group : userInfo.getGroups()) { sourceGroupsMap.put(userInfo.getLogin(), group); } } } Collection<String> sourceLoginNames = sourceLoginProps.stringPropertyNames(); if (sourceLoginNames.isEmpty()) { sourceLoginNames = sourceGroupsMap.keySet(); } boolean bulkMode = sourceLoginNames.size() > 1; for (String user : sourceLoginNames) { UserInfo sourceUserInfo = new UserInfo(); sourceUserInfo.setLogin(user); sourceUserInfo.setPassword((String) sourceLoginProps.get(user)); if (sourceGroupsMap.containsKey(user)) { sourceUserInfo.setGroups(sourceGroupsMap.get(user)); } switch (action) { case CREATE: createAccount(pubKey, sourceUserInfo, loginFilePath, groupFilePath, destinationLoginProps, destinationGroupsMap); break; case UPDATE: updateAccount(pubKey, sourceUserInfo, loginFilePath, destinationLoginProps, destinationGroupsMap, bulkMode); break; case DELETE: deleteAccount(sourceUserInfo, loginFilePath, groupFilePath, destinationLoginProps, destinationGroupsMap); break; } } storeLoginFile(loginFilePath, destinationLoginProps); storeGroups(groupFilePath, destinationGroupsMap); } catch (Throwable t) { exitWithErrorMessage("Unexpected error", null, t); } }
From source file:org.eclipse.xtext.xbase.typesystem.override.ResolvedFeatures.java
protected void computeAllOperations(JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations) { for (JvmOperation operation : type.getDeclaredOperations()) { boolean addToResult = true; if (targetVersion.isAtLeast(JavaVersion.JAVA8)) { addToResult = handleOverridesAndConflicts(operation, processedOperations); } else {/*w w w . ja v a 2s. co m*/ String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { addToResult = !isOverridden(operation, processedOperations.get(simpleName)); } } if (addToResult) { BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(operation.getSimpleName(), resolvedOperation); } } }
From source file:io.redlink.sdk.impl.analysis.model.RDFStructureParser.java
private void setEntityAnnotationData(EntityAnnotation entityAnnotation, BindingSet result, RepositoryConnection conn, Multimap<Enhancement, String> relations) throws RepositoryException, EnhancementParserException { if (!relations.containsKey(entityAnnotation)) { setEnhancementData(entityAnnotation, result); if (result.hasBinding("entityLabel")) { Binding entityLabel = result.getBinding("entityLabel"); entityAnnotation.setEntityLabel(entityLabel.getValue().stringValue()); if (!result.hasBinding("language") && (entityLabel.getValue() instanceof Literal)) entityAnnotation.setLanguage(((Literal) entityLabel.getValue()).getLanguage()); }/*from w ww . j a va 2s . c o m*/ if (result.hasBinding("site")) { entityAnnotation.setDataset(result.getBinding("site").getValue().stringValue()); } if (result.hasBinding("entityReference")) { entityAnnotation.setEntityReference( parseEntity(conn, result.getBinding("entityReference").getValue().stringValue(), entityAnnotation.getDataset())); } if (result.hasBinding("relation")) { String nextRelationUri = result.getBinding("relation").getValue().stringValue(); relations.put(entityAnnotation, nextRelationUri); } Collection<String> types = new HashSet<String>(); if (result.hasBinding("entityType")) { types.add(result.getBinding("entityType").getValue().stringValue()); } entityAnnotation.setEntityTypes(types); } else { if (result.hasBinding("relation")) { final String nextRelationUri = result.getBinding("relation").getValue().stringValue(); if (!relations.containsEntry(entityAnnotation, nextRelationUri)) relations.put(entityAnnotation, nextRelationUri); } if (result.hasBinding("entityType")) { final String entityType = result.getBinding("entityType").getValue().stringValue(); Collection<String> types = entityAnnotation.getEntityTypes(); Optional<String> eType = Iterables.tryFind(types, new Predicate<String>() { @Override public boolean apply(String arg0) { return arg0.equals(entityType); } }); if (!eType.isPresent()) types.add(entityType); } } }
From source file:com.wolvereness.overmapped.OverMapped.java
private void prepareSignatures(final Map<String, ByteClass> byteClasses, final Multimap<String, String> rdepends, final BiMap<String, String> nameMaps, final BiMap<Signature, Signature> signatureMaps) { for (final ByteClass clazz : byteClasses.values()) { if (missingAction == Missing.VERBOSE) { getLog().info("Loading class: " + clazz); }/*from w w w .j a v a 2 s.com*/ final String name = clazz.getToken(); nameMaps.put(name, name); final Iterable<String> reverseDependencies = rdepends.containsKey(name) ? rdepends.get(name) : ImmutableSet.<String>of(); for (final Signature signature : clazz.getLocalSignatures()) { signatureMaps.put(signature, signature); if (signature.isMethod() && !signature.isConstructor()) { for (final String rdepend : reverseDependencies) { final Signature newSignature = signature.forClassName(rdepend); signatureMaps.put(newSignature, newSignature); } } } } }
From source file:org.jabylon.updatecenter.repository.impl.OBRRepositoryConnectorImpl.java
private boolean applies(ResourceFilter filter, Multimap<String, Bundle> bundles, Resource resource) { switch (filter) { case ALL:/*from ww w .java 2 s .c o m*/ return true; case PLUGIN: String[] categories = resource.getCategories(); if (categories == null) return false; for (String string : categories) { if ("Jabylon-Plugin".equals(string)) return !bundles.containsKey(resource.getSymbolicName()); } return false; case INSTALLABLE: { // can install anything that isn't installed yet return !bundles.containsKey(resource.getSymbolicName()); } case UPDATEABLE: Collection<Bundle> installed = bundles.get(resource.getSymbolicName()); if (installed.isEmpty()) return false; // updateable if the latest installed version is less than // resource.getVersion return COMPARATOR.compare(installed.iterator().next().getVersion(), resource.getVersion()) > 0; case INSTALLED: Collection<Bundle> available = bundles.get(resource.getSymbolicName()); for (Bundle bundle : available) { if (bundle.getVersion().equals(resource.getVersion())) return true; } return false; default: break; } return true; }
From source file:com.facebook.buck.android.CompileStringsStep.java
/** * Similar to {@code scrapeStringNodes}, but for string array nodes. *//*from www.j av a 2 s. co m*/ @VisibleForTesting void scrapeStringArrayNodes(NodeList arrayNodes, Multimap<Integer, String> arraysMap) { for (int i = 0; i < arrayNodes.getLength(); ++i) { Node node = arrayNodes.item(i); String resourceName = node.getAttributes().getNamedItem("name").getNodeValue(); // Ignore a resource if R.txt does not contain an entry for it. if (!resourceNameToIdMap.containsKey(resourceName)) { continue; } int resourceId = resourceNameToIdMap.get(resourceName); // Ignore a resource if it has already been found. if (arraysMap.containsKey(resourceId)) { continue; } NodeList itemNodes = ((Element) node).getElementsByTagName("item"); for (int j = 0; j < itemNodes.getLength(); ++j) { arraysMap.put(resourceId, itemNodes.item(j).getTextContent()); } } }
From source file:org.sourcepit.maven.dependency.model.aether.DependencyModelBuildingGraphTransformer.java
private void handleArtifacts(Multimap<ArtifactKey, DependencyNode> keyToNodes, Collection<DependencyNode> nodes, Artifact artifact, boolean referenced) { final Set<ArtifactAttachment> attachments = handler.artifact(artifact, referenced); if (attachments != null) { for (ArtifactAttachment attachment : attachments) { Artifact attachedArtifact = artifactFactory.createArtifact(artifact, attachment.getClassifier(), attachment.getType()); final ArtifactKey attachmentKey = toArtifactKey(attachedArtifact); if (keyToNodes.containsKey(attachmentKey)) { attachedArtifact = keyToNodes.get(attachmentKey).iterator().next().getDependency() .getArtifact();//from w w w . j a v a 2 s . c o m } else { handleArtifacts(keyToNodes, nodes, attachedArtifact, referenced); } final String dataKey = attachment.isRequired() ? "requiredAttachments" : "optionalAttachments"; for (DependencyNode node : nodes) { @SuppressWarnings("unchecked") Set<Artifact> attachedArtifacts = (Set<Artifact>) node.getData().get(dataKey); if (attachedArtifacts == null) { attachedArtifacts = new LinkedHashSet<Artifact>(); node.setData(dataKey, attachedArtifacts); } attachedArtifacts.add(attachedArtifact); } } } }