List of usage examples for com.google.common.collect Multimap containsKey
boolean containsKey(@Nullable Object key);
From source file:org.eclipse.xtext.xbase.typesystem.override.ResolvedFeatures.java
/** * When the inherited operations are computed for Java 8, we have to check for conflicting default interface method implementations. *//*from w ww . j a va2s.c om*/ private boolean handleOverridesAndConflicts(JvmOperation operation, Multimap<String, AbstractResolvedOperation> processedOperations) { String simpleName = operation.getSimpleName(); if (!processedOperations.containsKey(simpleName)) { return true; } List<AbstractResolvedOperation> conflictingOperations = null; for (AbstractResolvedOperation candidate : processedOperations.get(simpleName)) { OverrideTester overrideTester = candidate.getOverrideTester(); IOverrideCheckResult checkResult = overrideTester.isSubsignature(candidate, operation, false); if (checkResult.getDetails().contains(OverrideCheckDetails.DEFAULT_IMPL_CONFLICT)) { // The current operation conflicts with the candidate if (conflictingOperations == null) conflictingOperations = Lists.newLinkedList(); conflictingOperations.add(candidate); } else if (checkResult.isOverridingOrImplementing()) { return false; } } if (conflictingOperations != null) { if (conflictingOperations.size() == 1 && conflictingOperations.get(0) instanceof ConflictingDefaultOperation) { // The current operation contributes to the already existing conflict ConflictingDefaultOperation conflictingDefaultOperation = (ConflictingDefaultOperation) conflictingOperations .get(0); boolean isOverridden = false; for (IResolvedOperation conflictingOp : conflictingDefaultOperation.getConflictingOperations()) { if (conflictingOp.getResolvedDeclarator().isSubtypeOf(operation.getDeclaringType())) { isOverridden = true; break; } } if (!isOverridden) conflictingDefaultOperation.getConflictingOperations().add(createResolvedOperation(operation)); return false; } // A new conflict of default implementations was found if (operation.isAbstract()) { ConflictingDefaultOperation resolvedOperation = createConflictingOperation( conflictingOperations.get(0).getDeclaration()); resolvedOperation.getConflictingOperations().add(createResolvedOperation(operation)); for (AbstractResolvedOperation conflictingOp : conflictingOperations) { processedOperations.remove(simpleName, conflictingOp); if (conflictingOp.getDeclaration() != resolvedOperation.getDeclaration()) { resolvedOperation.getConflictingOperations().add(conflictingOp); } } processedOperations.put(simpleName, resolvedOperation); } else { ConflictingDefaultOperation resolvedOperation = createConflictingOperation(operation); for (AbstractResolvedOperation conflictingOp : conflictingOperations) { processedOperations.remove(simpleName, conflictingOp); resolvedOperation.getConflictingOperations().add(conflictingOp); } processedOperations.put(simpleName, resolvedOperation); } return false; } return true; }
From source file:com.dmdirc.plugins.PluginMetaDataValidator.java
/** * Check if the services required by this plugin are available. * * @param knownServices A map of known services * @param services Required services *//*from ww w.j a v a 2s . c o m*/ private void checkServices(final Multimap<String, String> knownServices, final Collection<String> services) { if (services == null || services.isEmpty()) { return; } for (String requirement : services) { final String[] bits = requirement.split(" ", 2); final String name = bits[0]; final String type = bits[1]; if (!knownServices.containsKey(type) || !"any".equalsIgnoreCase(name) && !knownServices.containsEntry(type, name)) { errors.add("Service " + name + " of type " + type + " not available"); } } }
From source file:com.example.security.GroupBasedDefaultSecurityDimensionValuesProvider.java
/** * Order {@link com.i2group.disco.user.spi.DefaultSecurityDimension}s and default dimension value ids in schema order. */// w ww .ja v a 2s . c o m private Collection<com.i2group.disco.user.spi.DefaultSecurityDimension> createOrderedDefaultSecurityDimension( SecuritySchema securitySchema, Multimap<String, String> dimensionValueIdsByDimensionId) { final Collection<Dimension> schemaDimensions = securitySchema.getSecurityDimensions() .getAccessSecurityPermissions(); final Collection<com.i2group.disco.user.spi.DefaultSecurityDimension> result = new ArrayList<>(); for (Dimension schemaDimension : schemaDimensions) { final String dimensionId = schemaDimension.getId(); if (dimensionValueIdsByDimensionId.containsKey(dimensionId)) { final Collection<String> valueIds = dimensionValueIdsByDimensionId.get(dimensionId); final List<DimensionValue> schemaDimensionValues = schemaDimension.getValues(); final boolean isOrdered = schemaDimension.isOrdered(); final Collection<String> orderedValueIds = new ArrayList<>(); for (DimensionValue schemaDimensionValue : schemaDimensionValues) { final String schemaDimensionValueId = schemaDimensionValue.getId(); if (valueIds.contains(schemaDimensionValueId)) { orderedValueIds.add(schemaDimensionValueId); } // Only include 1 ordered dimension value id. if (isOrdered == true && !orderedValueIds.isEmpty()) { break; } } final com.i2group.disco.user.spi.DefaultSecurityDimension defaultSecurityDimension = new com.i2group.disco.user.spi.DefaultSecurityDimension( dimensionId, orderedValueIds); result.add(defaultSecurityDimension); } } return result; }
From source file:org.summer.dsl.xbase.typesystem.override.ResolvedOperations.java
protected void computeAllOperations(JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations, Set<JvmDeclaredType> processedTypes, List<IResolvedOperation> result) { if (type != null && !type.eIsProxy() && processedTypes.add(type)) { Iterable<JvmOperation> operations = type.getDeclaredOperations(); for (JvmOperation operation : operations) { String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (isOverridden(operation, processedOperations.get(simpleName))) { continue; }/* w w w .ja v a 2 s . c om*/ } BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(simpleName, resolvedOperation); result.add(resolvedOperation); } for (JvmTypeReference superType : type.getSuperTypes()) { JvmType rawSuperType = superType.getType(); if (rawSuperType instanceof JvmDeclaredType) { computeAllOperations((JvmDeclaredType) rawSuperType, processedOperations, processedTypes, result); } } } }
From source file:com.google.devtools.build.lib.pkgcache.LegacyLoadingPhaseRunner.java
private ImmutableSet<Target> filterErrorFreeTargets(EventHandler eventHandler, EventBus eventBus, TransitivePackageLoader pkgLoader, Collection<Target> targetsToLoad, ListMultimap<String, Label> labelsToLoadUnconditionally) throws LoadingFailedException { // Error out if any of the labels needed for the configuration could not be loaded. Multimap<Label, Label> rootCauses = pkgLoader.getRootCauses(); for (Map.Entry<String, Label> entry : labelsToLoadUnconditionally.entries()) { if (rootCauses.containsKey(entry.getValue())) { throw new LoadingFailedException( "Failed to load required " + entry.getKey() + " target: '" + entry.getValue() + "'"); }/*from ww w . j a v a2 s. co m*/ } // Post root causes for command-line targets that could not be loaded. for (Map.Entry<Label, Label> entry : rootCauses.entries()) { eventBus.post(new LoadingFailureEvent(entry.getKey(), entry.getValue())); } LoadedPackageProvider.Bridge bridge = new LoadedPackageProvider.Bridge(packageManager, eventHandler); return ImmutableSet.copyOf(Sets.difference(ImmutableSet.copyOf(targetsToLoad), getTargetsForLabels(bridge, rootCauses.keySet()))); }
From source file:edu.byui.firstproject.helloWorld.login.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww w . j ava 2 s. c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); // Check username if (request.getParameter("username") != null && request.getParameter("password") != null) { ServletContext context = getServletContext(); File file = new File("users.txt"); if (!file.exists()) { file.createNewFile(); FileWriter fileWriter = new FileWriter(file.getAbsoluteFile(), true); BufferedWriter bw = new BufferedWriter(fileWriter); bw.write("curtis,123"); bw.newLine(); bw.write("me,123"); bw.newLine(); bw.close(); } BufferedReader br = new BufferedReader(new FileReader("users.txt")); String line; Multimap<String, String> multimap = ArrayListMultimap.create(); while ((line = br.readLine()) != null) { System.out.println(line); String[] s = line.split(","); multimap.put(s[0], s[1]); } String username = request.getParameter("username"); String password = request.getParameter("password"); boolean valid_login = false; if (multimap.containsKey(username)) { if (multimap.get(username).contains(password)) { valid_login = true; } } if (valid_login) { HttpSession session = request.getSession(); session.setAttribute("username", username); session.setAttribute("incorrect_error", null); response.sendRedirect("forum.jsp"); } else { HttpSession session = request.getSession(); session.setAttribute("username", username); session.setAttribute("incorrect_error", null); response.sendRedirect("invalid.jsp"); } } }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.layout.horizontal.LostMessageEndHorizontalLayoutHelper.java
private int getLostMessageEndsGap(Lifeline lifeline, Multimap<Lifeline, LostMessageEnd> lostEnds, Range zone, Map<LostMessageEnd, Integer> lostEndsDelta, boolean revertDelta) { int gap = 0;// w w w. ja v a 2 s .c om if (lostEnds.containsKey(lifeline)) { int maxLostEndWidth = 0; int maxDelta = 0; int frameBorder = 0; for (LostMessageEnd lme : lostEnds.get(lifeline)) { // Message in zone ? if (zone == null || lostMessages.containsKey(lme) && zone.includesAtLeastOneBound(lostMessages.get(lme).getVerticalRange())) { int delta = lostEndsDelta.get(lme); maxDelta = Math.max(maxDelta, revertDelta ? -delta : delta); if (maxDelta > 0) { frameBorder = LayoutConstants.BORDER_FRAME_MARGIN; maxLostEndWidth = Math.max(maxLostEndWidth, lme.getProperLogicalBounds().width); } } } gap = maxDelta + maxLostEndWidth + frameBorder; } return gap; }
From source file:org.summer.dsl.xbase.typesystem.override.RawResolvedFeatures.java
protected void computeAllFeatures(JvmDeclaredType type, String name, Multimap<String, AbstractResolvedOperation> processedOperations, Set<String> processedFields, List<JvmFeature> result) { Iterable<JvmFeature> features = type.findAllFeaturesByName(name); for (JvmFeature feature : features) { if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (isOverridden(operation, processedOperations.get(simpleName))) { continue; }//w ww . jav a2 s . co m } BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(simpleName, resolvedOperation); result.add(operation); } else if (feature instanceof JvmField && processedFields.add(feature.getSimpleName())) { result.add(feature); } } }
From source file:org.raml.jaxrs.generator.builders.resources.ResourceBuilder.java
private void buildResource(TypeSpec.Builder typeSpec, GResource currentResource) { Multimap<GMethod, GRequest> incomingBodies = ArrayListMultimap.create(); Multimap<GMethod, GResponse> responses = ArrayListMultimap.create(); ResourceUtils.fillInBodiesAndResponses(currentResource, incomingBodies, responses); Map<String, TypeSpec.Builder> responseSpecs = createResponseClass(typeSpec, incomingBodies, responses); for (GMethod gMethod : currentResource.methods()) { String methodName = Names.resourceMethodName(gMethod.resource(), gMethod); Set<String> mediaTypesForMethod = fetchAllMediaTypesForMethodResponses(gMethod); if (gMethod.body().size() == 0) { createMethodWithoutBody(typeSpec, gMethod, mediaTypesForMethod, methodName, responseSpecs); } else {// w ww. j a v a 2 s .co m Multimap<String, String> ramlTypeToMediaType = accumulateMediaTypesPerType(incomingBodies, gMethod); for (GRequest gRequest : gMethod.body()) { if (ramlTypeToMediaType.containsKey(gRequest.type().name())) { createMethodWithBody(typeSpec, gMethod, ramlTypeToMediaType, methodName, gRequest, responseSpecs); ramlTypeToMediaType.removeAll(gRequest.type().name()); } } } } }
From source file:edu.umn.msi.tropix.webgui.server.forms.validation.SchemaParserImpl.java
private void topologicalSortVisit(final String node, final Multimap<String, String> dag, final List<String> sortedNodes, final Map<String, Color> nodeColors) { nodeColors.put(node, Color.GRAY); for (final String adjacentNode : dag.get(node)) { if (dag.containsKey(adjacentNode) && nodeColors.get(adjacentNode).equals(Color.WHITE)) { this.topologicalSortVisit(adjacentNode, dag, sortedNodes, nodeColors); }/* w ww . j a va 2 s. c om*/ } nodeColors.put(node, Color.BLACK); sortedNodes.add(node); }