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:com.mitre.fulfilmentprocess.test.ProcessFlowTest.java

@AfterClass
public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getApplicationContext();

    assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of "
            + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type "
            + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/mitrefulfilmentprocess/test/mitrefulfilmentprocess-spring-testcleanup.xml"));

    //cleanup command factory
    final Map<String, CommandFactory> commandFactoryList = applicationContext
            .getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;/*from   ww w. j  av  a 2s .  c  o m*/
    processService = null;
}

From source file:org.vinmonopolet.fulfilmentprocess.test.ProcessFlowTest.java

@AfterClass
public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getApplicationContext();

    assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of "
            + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type "
            + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/vinmonopoletfulfilmentprocess/test/vinmonopoletfulfilmentprocess-spring-testcleanup.xml"));

    //cleanup command factory
    final Map<String, CommandFactory> commandFactoryList = applicationContext
            .getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;//from  ww w.  ja  v  a2 s.  c o m
    processService = null;
}

From source file:org.training.fulfilmentprocess.test.ProcessFlowTest.java

@AfterClass
public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getApplicationContext();

    assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of "
            + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type "
            + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/trainingfulfilmentprocess/test/trainingfulfilmentprocess-spring-testcleanup.xml"));

    //cleanup command factory
    final Map<String, CommandFactory> commandFactoryList = applicationContext
            .getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;/*  ww w. j a  v a  2s . c om*/
    processService = null;
}

From source file:com.me.jvmi.Main.java

public static Collection<InputRecord> parseInput(Path csv) throws IOException {
    Map<String, InputRecord> records = new HashMap<>();
    CSVParser parser = CSVParser.parse(csv.toFile(), Charset.forName("UTF-8"), CSVFormat.DEFAULT.withHeader());

    for (CSVRecord record : parser) {
        InputRecord input = new InputRecord(record);
        records.put(input.getId(), input);
    }// ww  w. j a  va 2 s .co  m

    for (InputRecord record : records.values()) {
        if (record.isPackage()) {
            for (String id : record.packageIds) {
                if (!records.containsKey(id)) {
                    throw new IllegalStateException("Could not find product for package id: " + id);
                }
                record.addItem(records.get(id));
            }
        }
    }

    return records.values();
}

From source file:ReflectUtil.java

/**
 * Fetches all fields of all access types from the supplied class and super
 * classes. Fieldss that have been overridden in the inheritance hierarchy are
 * only returned once, using the instance lowest down the hierarchy.
 *
 * @param clazz the class to inspect//www  .  ja va  2 s.c om
 * @return a collection of fields
 */
public static Collection<Field> getFields(Class<?> clazz) {
    Map<String, Field> fields = new HashMap<String, Field>();
    while (clazz != null) {
        for (Field field : clazz.getDeclaredFields()) {
            if (!fields.containsKey(field.getName())) {
                fields.put(field.getName(), field);
            }
        }

        clazz = clazz.getSuperclass();
    }

    return fields.values();
}

From source file:com.github.aptd.simulation.datamodel.CXMLReader.java

/**
 * create the station list/*  www  . j  a  v  a  2 s . c  om*/
 *
 * @param p_network network component
 * @param p_agents map with agent asl scripts
 * @param p_factory factory
 * @param p_time time reference
 * @param p_platforms map with already generated platforms
 * @return unmodifyable map with stations
 */
private static Map<String, IStation<?>> station(final Network p_network, final Map<String, String> p_agents,
        final IFactory p_factory, final ITime p_time, final Map<String, IPlatform<?>> p_platforms) {
    final Map<String, IElement.IGenerator<IStation<?>>> l_generators = new ConcurrentHashMap<>();
    final Set<IAction> l_actions = CCommon.actionsFromPackage().collect(Collectors.toSet());
    final ListMultimap<String, IPlatform<?>> l_platformbystationid = Multimaps.index(p_platforms.values(),
            IPlatform::stationid);
    return Collections.<String, IStation<?>>unmodifiableMap(p_network
            .getInfrastructure().getOperationControlPoints().getOcp().parallelStream().filter(
                    i -> hasagentname(i.getAny()))
            .map(i -> agentname(i, i.getAny()))
            .map(i -> l_generators
                    .computeIfAbsent(i.getRight(),
                            a -> stationgenerator(p_factory, p_agents.get(i.getRight()), l_actions, p_time))
                    .generatesingle(i.getLeft().getId(), i.getLeft().getGeoCoord().getCoord().get(0),
                            i.getLeft().getGeoCoord().getCoord().get(1),
                            l_platformbystationid.get(i.getLeft().getId())))
            .collect(Collectors.toMap(IElement::id, i -> i)));
}

From source file:com.diversityarrays.kdxplore.field.FieldViewPanel.java

/**
 * Create a new FieldViewPanel using the caller-provided VisitOrder2D and PlotsPerGroup.
 * @param database/*from  ww w  .j  a  va  2s  . c  om*/
 * @param trial
 * @param visitOrder
 * @param plotsPerGroup
 * @return
 * @throws IOException
 */
public static FieldViewPanel create(KDSmartDatabase database, Trial trial, VisitOrder2D visitOrder,
        PlotsPerGroup plotsPerGroup, SimplePlotCellRenderer plotRenderer,
        SeparatorVisibilityOption visibilityOption, Component... extras) throws IOException {
    Map<WhyMissing, List<String>> missing = new TreeMap<>();

    Closure<Pair<WhyMissing, MediaFileRecord>> reportMissing = new Closure<Pair<WhyMissing, MediaFileRecord>>() {
        @Override
        public void execute(Pair<WhyMissing, MediaFileRecord> pair) {
            WhyMissing why = pair.first;
            MediaFileRecord mfr = pair.second;
            List<String> list = missing.get(why);
            if (list == null) {
                list = new ArrayList<>();
                missing.put(why, list);
            }
            list.add(mfr.getFilePath());
        }
    };

    int trialId = trial.getTrialId();
    Map<Integer, Plot> plotById = DatabaseUtil.collectPlotsIncludingMediaFiles(database, trialId,
            "FieldViewPanel", SampleGroupChoice.ANY_SAMPLE_GROUP, reportMissing);

    List<Plot> plots = new ArrayList<>(plotById.values());

    if (!missing.isEmpty()) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                StringBuilder html = new StringBuilder("<HTML><DL>");
                for (WhyMissing why : missing.keySet()) {
                    html.append("<DT>").append(why.name()).append("</DT><DD>");
                    List<String> list = missing.get(why);
                    if (list.size() == 1) {
                        html.append(StringUtil.htmlEscape(list.get(0)));
                    } else {
                        html.append("<UL>");
                        for (String s : list) {
                            html.append("<LI>").append(StringUtil.htmlEscape(s)).append("</LI>");
                        }
                        html.append("</UL>");
                    }
                    html.append("</DD>");
                }
                html.append("</DL>");
                MsgBox.warn(null, html.toString(), "Missing Files");
            }
        });
    }

    Map<Integer, Trait> traitMap = new HashMap<>();
    database.getTrialTraits(trialId).stream().forEach(t -> traitMap.put(t.getTraitId(), t));

    List<TraitInstance> traitInstances = new ArrayList<>();
    Predicate<TraitInstance> traitInstanceVisitor = new Predicate<TraitInstance>() {
        @Override
        public boolean evaluate(TraitInstance ti) {
            traitInstances.add(ti);
            return true;
        }
    };
    database.visitTraitInstancesForTrial(trialId, KDSmartDatabase.WithTraitOption.ALL_WITH_TRAITS,
            traitInstanceVisitor);

    PlotVisitList plotVisitList = buildPlotVisitList(trial, visitOrder, plotsPerGroup, traitMap, traitInstances,
            plots);

    if (plotRenderer == null) {
        plotRenderer = new SimplePlotCellRenderer();
    }
    return new FieldViewPanel(plotVisitList, traitMap, visibilityOption, plotRenderer, extras);
}

From source file:com.vmware.photon.controller.common.xenon.ServiceHostUtils.java

public static <H extends ServiceHost> void deleteAllDocuments(H host, String referrer, long timeout,
        TimeUnit timeUnit) throws Throwable {
    QueryTask.Query selfLinkClause = new QueryTask.Query()
            .setTermPropertyName(ServiceDocument.FIELD_NAME_SELF_LINK).setTermMatchValue("/photon/*")
            .setTermMatchType(QueryTask.QueryTerm.MatchType.WILDCARD);

    QueryTask.QuerySpecification querySpecification = new QueryTask.QuerySpecification();
    querySpecification.query.addBooleanClause(selfLinkClause);
    QueryTask queryTask = QueryTask.create(querySpecification).setDirect(true);

    NodeGroupBroadcastResponse queryResponse = ServiceHostUtils.sendBroadcastQueryAndWait(host, referrer,
            queryTask);/*from ww w . ja v a2 s. co  m*/

    Set<String> documentLinks = QueryTaskUtils.getBroadcastQueryDocumentLinks(queryResponse);

    if (documentLinks == null || documentLinks.size() <= 0) {
        return;
    }

    CountDownLatch latch = new CountDownLatch(1);

    OperationJoin.JoinedCompletionHandler handler = new OperationJoin.JoinedCompletionHandler() {
        @Override
        public void handle(Map<Long, Operation> ops, Map<Long, Throwable> failures) {
            if (failures != null && !failures.isEmpty()) {
                for (Throwable e : failures.values()) {
                    logger.error("deleteAllDocuments failed", e);
                }
            }
            latch.countDown();
        }
    };

    Collection<Operation> deletes = new LinkedList<>();
    for (String documentLink : documentLinks) {
        Operation deleteOperation = Operation.createDelete(UriUtils.buildUri(host, documentLink)).setBody("{}")
                .setReferer(UriUtils.buildUri(host, referrer));
        deletes.add(deleteOperation);
    }

    OperationJoin join = OperationJoin.create(deletes);
    join.setCompletion(handler);
    join.sendWith(host);
    if (!latch.await(timeout, timeUnit)) {
        throw new TimeoutException(String
                .format("Deletion of all documents timed out. Timeout:{%s}, TimeUnit:{%s}", timeout, timeUnit));
    }
}

From source file:com.alibaba.jstorm.ui.UIUtils.java

public static TableData getComponentTable(TopologyInfo topologyInfo, List<ComponentSummary> componentSummaries,
        Map<String, MetricInfo> componentMetrics, Map<String, String> paramMap, Integer window) {
    TableData table = new TableData();
    List<String> headers = table.getHeaders();
    List<Map<String, ColumnData>> lines = table.getLines();

    List<String> keys = UIUtils.getSortedKeys(UIUtils.getKeys(componentMetrics.values()));

    headers.add(UIDef.HEADER_COMPONENT_NAME);
    headers.add(UIDef.HEADER_TASK_NUM);/*from w  w w.  ja va 2s. c o m*/
    headers.addAll(keys);
    headers.add(UIDef.HEADER_ERROR);

    for (ComponentSummary componentSummary : componentSummaries) {
        Map<String, ColumnData> line = new HashMap<String, ColumnData>();
        lines.add(line);

        String name = componentSummary.get_name();

        ColumnData nameColumnData = new ColumnData();
        LinkData linkData = new LinkData();
        nameColumnData.addLinkData(linkData);
        line.put(UIDef.HEADER_COMPONENT_NAME, nameColumnData);

        linkData.setUrl(UIDef.LINK_WINDOW_TABLE);
        linkData.setText(name);
        linkData.addParam(UIDef.CLUSTER, paramMap.get(UIDef.CLUSTER));
        linkData.addParam(UIDef.PAGE_TYPE, UIDef.PAGE_TYPE_COMPONENT);
        linkData.addParam(UIDef.TOPOLOGY, topologyInfo.get_topology().get_id());
        linkData.addParam(UIDef.COMPONENT, name);

        ColumnData taskNumColumn = new ColumnData();
        taskNumColumn.addText(String.valueOf(componentSummary.get_parallel()));
        line.put(UIDef.HEADER_TASK_NUM, taskNumColumn);

        ColumnData errColumn = new ColumnData();
        line.put(UIDef.HEADER_ERROR, errColumn);
        List<ErrorInfo> errs = componentSummary.get_errors();
        if (errs == null) {
            errColumn.addText("");

        } else {
            for (ErrorInfo err : errs) {
                errColumn.addText(err.get_error() + "\r\n");
            }

        }

        MetricInfo metric = componentMetrics.get(name);
        if (metric == null) {
            continue;
        }

        for (String key : keys) {
            String value = UIUtils.getValue(metric, key, window);
            ColumnData columnData = new ColumnData();
            columnData.addText(value);
            line.put(key, columnData);

        }

    }

    return table;
}

From source file:com.utdallas.s3lab.smvhunter.enumerate.UIEnumerator.java

/**
 * Remove duplicate viewnodes from list/*from w w  w. j ava  2s .com*/
 * @param nodeList
 * @return
 */
private static List<ViewNode> removeDuplicates(List<ViewNode> nodeList) {
    Map<String, ViewNode> map = new TreeMap<String, ViewNode>();

    for (ViewNode node : nodeList) {
        Point pt = HierarchyViewer.getAbsolutePositionOfView(node);
        map.put(String.format("%d%d", pt.x, pt.y), node);
    }

    return new ArrayList<ViewNode>(map.values());
}