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.expedia.tesla.compiler.Util.java

/**
 * Get a set of all user types defined in all schemas. It's the union of all
 * user type definitions.//from  ww w  .  j a  v a  2 s.  c o m
 * 
 * @param schemas
 *            A collection of Tesla schema objects.
 * @return A set of all user types defined in all schemas
 */
public static Collection<UserType> getAllUserTypes(Collection<Schema> schemas) {
    Map<String, UserType> all = new TreeMap<String, UserType>();
    for (Schema schema : schemas) {
        for (UserType t : schema.getUserTypes()) {
            all.put(t.getName(), t);
        }
    }
    return all.values();
}

From source file:com.taobao.android.builder.tools.bundleinfo.BundleGraphExecutor.java

private static Map<String, BundleItem> getBundleItemMap(Map<String, BundleInfo> bundleInfoMap) {
    Map<String, BundleItem> bundleItemMap = new HashMap<>();
    for (BundleInfo bundleInfo : bundleInfoMap.values()) {

        BundleItem bundleItem = bundleItemMap.get(bundleInfo.getPkgName());

        if (null == bundleItem) {
            bundleItem = new BundleItem();
            bundleItem.bundleInfo = bundleInfo;
            bundleItemMap.put(bundleInfo.getPkgName(), bundleItem);
        }//from ww  w . ja v a2 s .c om

        //Computing rely on
        for (String dependency : bundleInfo.getDependency()) {
            if (StringUtils.isNotEmpty(dependency)) {
                BundleItem child = bundleItemMap.get(dependency);
                if (null == child) {
                    child = new BundleItem();
                    child.bundleInfo = bundleInfoMap.get(dependency);
                    if (null == child.bundleInfo) {
                        throw new GradleException("bundle dependency is error , not bundle found for "
                                + dependency + " ; which may define in " + bundleInfo.getPkgName());
                    }
                    bundleItemMap.put(dependency, child);
                }

                bundleItem.children.add(child);
                child.parents.add(bundleItem);
            }
        }

    }
    return bundleItemMap;
}

From source file:se.uu.it.cs.recsys.ruleminer.datastructure.builder.FPTreeHeaderTableBuilder.java

/**
 *
 * @param idAndCount item id and count//w w w .  ja v a 2s  . co  m
 * @param threshold, min support
 * @return non-null HeaderTableItem if the input contains id meets threshold
 * requirement; otherwise null.
 */
public static List<HeaderTableItem> build(Map<Integer, Integer> idAndCount, Integer threshold) {

    List<HeaderTableItem> instance = new ArrayList<>();

    Map<Integer, Integer> filteredIdAndCount = Util.filter(idAndCount, threshold);

    if (filteredIdAndCount.isEmpty()) {
        LOGGER.debug("Empty map after filtering. Empty list will be returned. Source: {}", idAndCount);
        return instance;
    }

    List<Integer> countList = new ArrayList<>(filteredIdAndCount.values());
    Collections.sort(countList);
    Collections.reverse(countList);// now the count is in DESC order

    for (int i = 1; i <= filteredIdAndCount.size(); i++) {
        instance.add(new HeaderTableItem()); // in order to call list.set(idx,elem)
    }

    Map<Integer, Set<Integer>> forIdsHavingSameCount = new HashMap<>();//different ids may have same count

    filteredIdAndCount.entrySet().forEach((entry) -> {
        Integer courseId = entry.getKey();
        Integer count = entry.getValue();

        Integer countFrequence = Collections.frequency(countList, count);

        if (countFrequence == 1) {
            Integer countIdx = countList.indexOf(count);
            instance.set(countIdx, new HeaderTableItem(new Item(courseId, count)));
        } else {
            // different ids have same count

            if (!forIdsHavingSameCount.containsKey(count)) {
                forIdsHavingSameCount.put(count, Util.findDuplicatesIndexes(countList, count));
            }

            Iterator<Integer> itr = forIdsHavingSameCount.get(count).iterator();
            Integer idx = itr.next();
            itr.remove();

            instance.set(idx, new HeaderTableItem(new Item(courseId, count)));
        }

    });

    //        LOGGER.debug("Final built header table: {}",
    //                instance.stream()
    //                .map(headerItem -> headerItem.getItem()).collect(Collectors.toList()));

    return instance;
}

From source file:com.opengamma.analytics.financial.riskfactor.TaylorExpansionMultiplierCalculator.java

public static DoubleTimeSeries<?> getTimeSeries(final Map<UnderlyingType, DoubleTimeSeries<?>> underlyingData,
        final Underlying underlying) {
    Validate.notNull(underlying, "underlying");
    Validate.notNull(underlyingData, "underlying data");
    Validate.notEmpty(underlyingData, "underlying data");
    Validate.noNullElements(underlyingData.keySet(), "underlying data keys");
    Validate.noNullElements(underlyingData.values(), "underlying data values");
    if (underlying instanceof NthOrderUnderlying) {
        final NthOrderUnderlying nthOrder = (NthOrderUnderlying) underlying;
        final int n = nthOrder.getOrder();
        if (n == 0) {
            throw new UnsupportedOperationException();
        }/*ww  w . j  ava2s  .  c o  m*/
        final UnderlyingType type = nthOrder.getUnderlying();
        Validate.isTrue(underlyingData.containsKey(type));
        DoubleTimeSeries<?> ts = underlyingData.get(type);
        ts = ts.power(n);
        return ts.multiply(getMultiplier(underlying));
    } else if (underlying instanceof MixedOrderUnderlying) {
        final MixedOrderUnderlying mixedOrder = (MixedOrderUnderlying) underlying;
        DoubleTimeSeries<?> result = null;
        DoubleTimeSeries<?> multiplier = null;
        int size = 0;
        for (final NthOrderUnderlying underlyingOrder : mixedOrder.getUnderlyingOrders()) {
            if (result == null) {
                result = getTimeSeries(underlyingData, underlyingOrder);
                size = result.size();
            } else {
                multiplier = getTimeSeries(underlyingData, underlyingOrder);
                if (multiplier.size() != size) {
                    throw new IllegalArgumentException("Time series in map were not the same length");
                }
                result = result.multiply(multiplier);
                if (result.size() != size) {
                    throw new IllegalArgumentException("Time series in map did not contain the same times");
                }
            }
        }
        return result;
    }
    throw new IllegalArgumentException(
            "Order was neither NthOrderUnderlying nor MixedOrderUnderlying: have " + underlying.getClass());
}

From source file:gr.abiss.calipso.jpasearch.specifications.GenericSpecifications.java

protected static void addJunctionedParams(final Class clazz, Root<Persistable> root, CriteriaBuilder cb,
        LinkedList<Predicate> predicates, Map<String, Map<String, String[]>> andJunctions, String mode) {
    if (!CollectionUtils.isEmpty(andJunctions)) {
        String[] searchMode = { mode };
        for (Map<String, String[]> params : andJunctions.values()) {
            params.put(SEARCH_MODE, searchMode);
            Predicate nestedPredicate = getRootPredicate(clazz, params, root, cb, true);
            if (nestedPredicate != null) {
                predicates.add(nestedPredicate);
            }/*from  w ww.ja  v a  2  s  .c  o m*/
        }
    }
}

From source file:azkaban.reportal.util.ReportalHelper.java

/**
 * Updates the email notifications saved in the project's flow.
 * @param project/*from w  w w . j a va 2s .c om*/
 * @param pm
 * @throws ProjectManagerException
 */
public static void updateProjectNotifications(Project project, ProjectManager pm)
        throws ProjectManagerException {
    Flow flow = project.getFlows().get(0);

    // Get all success emails.
    ArrayList<String> successEmails = new ArrayList<String>();
    String successNotifications = (String) project.getMetadata().get("notifications");
    String[] successEmailSplit = successNotifications.split("\\s*,\\s*|\\s*;\\s*|\\s+");
    successEmails.addAll(Arrays.asList(successEmailSplit));

    // Get all failure emails.
    ArrayList<String> failureEmails = new ArrayList<String>();
    String failureNotifications = (String) project.getMetadata().get("failureNotifications");
    String[] failureEmailSplit = failureNotifications.split("\\s*,\\s*|\\s*;\\s*|\\s+");
    failureEmails.addAll(Arrays.asList(failureEmailSplit));

    // Add subscription emails to success emails list.
    @SuppressWarnings("unchecked")
    Map<String, String> subscription = (Map<String, String>) project.getMetadata().get("subscription");
    if (subscription != null) {
        successEmails.addAll(subscription.values());
    }

    ArrayList<String> successEmailList = new ArrayList<String>();
    for (String email : successEmails) {
        if (!email.trim().isEmpty()) {
            successEmailList.add(email);
        }
    }

    ArrayList<String> failureEmailList = new ArrayList<String>();
    for (String email : failureEmails) {
        if (!email.trim().isEmpty()) {
            failureEmailList.add(email);
        }
    }

    // Save notifications in the flow.
    flow.getSuccessEmails().clear();
    flow.getFailureEmails().clear();
    flow.addSuccessEmails(successEmailList);
    flow.addFailureEmails(failureEmailList);
    pm.updateFlow(project, flow);
}

From source file:edu.internet2.middleware.shibboleth.common.attribute.AttributeAuthorityCLI.java

/**
 * Constructs a SAML 1 attribute statement with the retrieved and filtered attributes.
 * /*from  w  w w  .j  a  v a 2 s.  c om*/
 * @param parser command line arguments
 * @param appCtx spring application context with loaded attribute authority
 * 
 * @return SAML 1 attribute statement
 */
private static SAMLObject performSAML1AttributeResolution(CmdLineParser parser, ApplicationContext appCtx) {
    BaseSAMLProfileRequestContext requestCtx = buildAttributeRequestContext(parser, appCtx);

    try {
        Map<String, BaseAttribute> attributes = saml1AA.getAttributes(requestCtx);
        return saml1AA.buildAttributeStatement(null, attributes.values());
    } catch (AttributeRequestException e) {
        errorAndExit("Error encountered during attribute resolution and filtering", e);
    }

    return null;
}

From source file:edu.internet2.middleware.shibboleth.common.attribute.AttributeAuthorityCLI.java

/**
 * Constructs a SAML 2 attribute statement with the retrieved and filtered attributes.
 * // ww w  .j  a  v a2s  . c  o  m
 * @param parser command line arguments
 * @param appCtx spring application context with loaded attribute authority
 * 
 * @return SAML 2 attribute statement
 */
private static SAMLObject performSAML2AttributeResolution(CmdLineParser parser, ApplicationContext appCtx) {
    BaseSAMLProfileRequestContext requestCtx = buildAttributeRequestContext(parser, appCtx);

    try {
        Map<String, BaseAttribute> attributes = saml2AA.getAttributes(requestCtx);
        return saml2AA.buildAttributeStatement(null, attributes.values());
    } catch (AttributeRequestException e) {
        errorAndExit("Error encountered during attribute resolution and filtering", e);
    }

    return null;
}

From source file:org.opensprout.osaf.util.ApplicationContextUtils.java

public static <T> T getBeanByType(ApplicationContext applicationContext, Class<T> clazz) {
    Map beanMap = applicationContext.getBeansOfType(clazz);
    int size = beanMap.size();
    if (size == 0) {
        if (applicationContext.getParent() != null)
            return getBeanByType(applicationContext.getParent(), clazz);
        throw new NoSuchBeanDefinitionException(clazz.getSimpleName());
    }/*from   www .j  av  a2s . co  m*/
    if (size > 1)
        throw new NoSuchBeanDefinitionException(
                "No unique bean definition type [" + clazz.getSimpleName() + "]");
    return (T) beanMap.values().iterator().next();
}

From source file:net.greghaines.jesque.web.controller.JesqueController.java

private static long totalWorkerInfoCount(final Map<?, List<WorkerInfo>> hostMap) {
    long count = 0;
    for (final List<WorkerInfo> workerInfos : hostMap.values()) {
        count += workerInfos.size();/*from ww w  .  j a v a  2 s  .c  o  m*/
    }
    return count;
}