Example usage for java.util Map values

List of usage examples for java.util Map values

Introduction

In this page you can find the example usage for java.util Map values.

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:edu.umd.umiacs.clip.tools.scor.IndriBM25Scorer.java

@Override
public float scoreProcessed(Object query, Object text) {
    Map<String, Integer> docTerms = (Map<String, Integer>) text;
    int length = docTerms.values().stream().mapToInt(f -> f).sum();
    return (float) ((List<Pair<List<Pair<String, Float>>, Float>>) query).parallelStream()
            .mapToDouble(p -> bm25((float) p.getLeft().parallelStream()
                    .mapToDouble(pair -> pair.getRight() * docTerms.getOrDefault(pair.getLeft(), 0)).sum(),
                    p.getRight(), length))
            .sum();/*from  w ww.j a  v a2  s  .  com*/
}

From source file:org.urbantower.j4s.AutowiredHandlerCollection.java

@Override
public void afterPropertiesSet() throws Exception {
    Map<String, Handler> handlers = applicationContext.getBeansOfType(Handler.class);
    for (Handler h : handlers.values()) {
        if (h.getClass() != SpringServer.class) {
            this.addHandler(h);
        }//  www.j a v a2 s.com
    }
}

From source file:org.vbossica.springbox.metrics.HealthCheckController.java

private boolean isAllHealthy(Map<String, HealthCheck.Result> results) {
    for (HealthCheck.Result result : results.values()) {
        if (!result.isHealthy()) {
            return false;
        }/*  www.  jav  a 2s.c  om*/
    }
    return true;
}

From source file:com.thoughtworks.go.agent.testhelpers.FakeArtifactPublisherServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
    MultipartHttpServletRequest httpServletRequest = multipartResolver.resolveMultipart(request);
    Map<String, MultipartFile> map = httpServletRequest.getFileMap();
    MultipartFile multipartFile = map.values().iterator().next();
    receivedFiles.add(multipartFile.getOriginalFilename());
}

From source file:eu.itesla_project.modules.validation.OfflineValidationTool.java

private static void writeAttributesFiles(Set<RuleId> rulesIds,
        Map<String, Map<RuleId, Map<HistoDbAttributeId, Object>>> valuesPerRulePerCase, Path outputDir)
        throws IOException {
    for (RuleId ruleId : rulesIds) {
        Path attributesFile = outputDir.resolve("attributes_" + ruleId.toString() + ".csv");

        System.out.println("writing " + attributesFile + "...");

        try (BufferedWriter writer = Files.newBufferedWriter(attributesFile, StandardCharsets.UTF_8)) {
            writer.write("base case");

            Set<HistoDbAttributeId> allAttributeIds = new LinkedHashSet<>();
            for (Map<RuleId, Map<HistoDbAttributeId, Object>> valuesPerRule : valuesPerRulePerCase.values()) {
                Map<HistoDbAttributeId, Object> values = valuesPerRule.get(ruleId);
                if (values != null) {
                    allAttributeIds.addAll(values.keySet());
                }/*ww w  .  j a v a2s  .  c o  m*/
            }

            for (HistoDbAttributeId attributeId : allAttributeIds) {
                writer.write(CSV_SEPARATOR);
                writer.write(attributeId.toString());
            }
            writer.newLine();

            for (Map.Entry<String, Map<RuleId, Map<HistoDbAttributeId, Object>>> e : valuesPerRulePerCase
                    .entrySet()) {
                String baseCaseName = e.getKey();
                Map<RuleId, Map<HistoDbAttributeId, Object>> valuesPerRule = e.getValue();
                writer.write(baseCaseName);

                Map<HistoDbAttributeId, Object> values = valuesPerRule.get(ruleId);
                for (HistoDbAttributeId attributeId : allAttributeIds) {
                    writer.write(CSV_SEPARATOR);
                    Object value = values.get(attributeId);
                    if (value != null && !(value instanceof Float && Float.isNaN((Float) value))) {
                        writer.write(Objects.toString(values.get(attributeId)));
                    }
                }

                writer.newLine();
            }
        }
    }
}

From source file:org.openmrs.module.pihmalawi.sql.MysqlRunnerTest.java

@Override
protected void performTest() throws Exception {

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("gender", "F");

    MysqlResult result = MysqlRunner.executeSqlResource("org/openmrs/module/pihmalawi/sql/simpleScript.sql",
            parameters);/*from   w  w  w.j a v a  2  s  .c o m*/

    System.out.println(result.getData().size() + " results found");
    System.out.println("------ RESULTS -----");
    System.out.println(OpenmrsUtil.join(result.getColumns(), "\t\t"));
    for (Map<String, String> row : result.getData()) {
        System.out.println(OpenmrsUtil.join(row.values(), "\t\t"));
    }
    System.out.println("------ ERRORS -----");
    for (String error : result.getErrors()) {
        System.out.println(error);
    }
}

From source file:by.creepid.docgeneration.validation.ValidatorPhaseListener.java

private void processValidators(Map scope, FacesContext facesContext) {
    Collection collection = scope.values();

    for (Object object : collection) {
        if (object instanceof Validatable) {
            validateValidatable((Validatable) object, facesContext);
        }/*from ww  w .ja  v  a2 s .  c o  m*/
    }
}

From source file:com.google.api.codegen.config.GapicProductConfig.java

private static <T extends ResourceNameConfig> ImmutableMap<String, T> mergeResourceNameConfigs(
        DiagCollector diagCollector, Map<String, T> configsFromGapicConfig,
        Map<String, T> configsFromProtoFile) {
    Map<String, T> mergedResourceNameConfigs = new HashMap<>(configsFromProtoFile);

    // If protofile annotations clash with the configs from configProto, use the configProto.
    for (T resourceFromGapicConfig : configsFromGapicConfig.values()) {
        if (configsFromProtoFile.containsKey(resourceFromGapicConfig.getEntityId())) {
            diagCollector.addDiag(Diag.warning(SimpleLocation.TOPLEVEL,
                    "Resource[Set] entity %s from protofile clashes with a"
                            + " Resource[Set] of the same name from the GAPIC config."
                            + " Using the GAPIC config entity.",
                    resourceFromGapicConfig.getEntityId()));
        }// w  w  w  .  j av  a 2  s  .c  om
        // Add the protofile resourceNameConfigs to the map of resourceNameConfigs.
        mergedResourceNameConfigs.put(resourceFromGapicConfig.getEntityId(), resourceFromGapicConfig);
    }
    return ImmutableMap.copyOf(mergedResourceNameConfigs);
}

From source file:at.ac.tuwien.dsg.smartcom.integration.JSONConverter.java

public static PeerInfo getPeerInfo(Identifier peerId, String content) throws NoSuchPeerException {
    JSONObject jsonOutput = (JSONObject) JSONValue.parse(content);

    String[][] strings = parsePeerInfoResults(jsonOutput);

    if (strings == null) {
        throw new NoSuchPeerException(peerId);
    }/*from   ww w  .j a v  a 2s .c  o  m*/

    PeerInfo info = new PeerInfo();
    info.setId(peerId);
    info.setPrivacyPolicies(null);

    Map<String, PeerChannelAddress> map = new HashMap<>();

    for (String[] string : strings) {
        info.setDeliveryPolicy(DeliveryPolicy.Peer.values()[(int) Integer.valueOf(string[3])]);

        String id = string[2];

        PeerChannelAddress address = map.get(id);
        if (address == null) {
            address = new PeerChannelAddress();
            address.setPeerId(peerId);
            address.setContactParameters(new ArrayList<String>());
            address.setChannelType(Identifier.channelType(string[4]));
            map.put(id, address);
        }

        if (address.getContactParameters() == null) {
            address.setContactParameters(new ArrayList<String>());
        }

        ArrayList<String> list = (ArrayList<String>) address.getContactParameters();
        list.add(string[5]);
    }

    List<PeerChannelAddress> addresses = new ArrayList<>(map.values());
    info.setAddresses(addresses);

    return info;
}

From source file:org.zalando.riptide.ContentTypeSelector.java

private Supplier<Optional<Binding<MediaType>>> bestMatch(final Optional<MediaType> attribute,
        final Map<Optional<MediaType>, Binding<MediaType>> bindings) {
    return () -> attribute.flatMap(a -> bindings.values().stream().filter(b -> b.getAttribute().isPresent())
            .sorted(BY_SPECIFICITY).filter(b -> b.getAttribute().get().includes(a)).findFirst());
}