List of usage examples for java.util Map values
Collection<V> values();
From source file:org.springframework.hateoas.config.EnableHypermediaSupportIntegrationTest.java
private static void assertEntityLinksSetUp(ApplicationContext context) { Map<String, EntityLinks> discoverers = context.getBeansOfType(EntityLinks.class); assertThat(discoverers.values(), Matchers.<EntityLinks>hasItem(instanceOf(DelegatingEntityLinks.class))); }
From source file:org.springframework.hateoas.config.EnableHypermediaSupportIntegrationTest.java
private static void assertRelProvidersSetUp(ApplicationContext context) { Map<String, RelProvider> discoverers = context.getBeansOfType(RelProvider.class); assertThat(discoverers.values(), Matchers.<RelProvider>hasItem(instanceOf(DelegatingRelProvider.class))); }
From source file:cc.kave.commons.pointsto.evaluation.runners.ProjectStoreRunner.java
private static void countUsages(Collection<ICoReTypeName> types, ProjectUsageStore store) throws IOException { int totalNumberOfProjects = store.getNumberOfProjects(); for (ICoReTypeName type : types) { int numProjects = store.getProjects(type).size(); if (numProjects < 10) { continue; }//from w ww. ja v a 2 s. com Map<ProjectIdentifier, Integer> usageCounts = store.getNumberOfUsagesPerProject(type); DescriptiveStatistics statistics = new DescriptiveStatistics(); usageCounts.values().forEach(count -> statistics.addValue(count)); for (int i = 0; i < totalNumberOfProjects - numProjects; ++i) { statistics.addValue(0); } System.out.printf(Locale.US, "%s: %.1f\n", CoReNames.vm2srcQualifiedType(type), statistics.getStandardDeviation()); } }
From source file:Main.java
public static <K, V> List<Integer> getIndexListByValues(Map<K, V> map, Object[] values) { if ((values == null) || (values.length == 0)) { return null; }/* w w w . j a va2 s. com*/ List<Integer> indexList = new ArrayList<Integer>(map.size()); Integer i = Integer.valueOf(0); for (V v : map.values()) { for (Object value : values) { if ((v == value) || (v.equals(value))) { indexList.add(i); } } i = Integer.valueOf(i.intValue() + 1); } return indexList; }
From source file:com.feedzai.commons.sql.abstraction.engine.testconfig.DatabaseTestUtil.java
/** * Loads and transforms the configurations from {@code CONFIGURATION_FILE}. * * @return The instances to test defined in the configuration file. * @throws Exception If something occurs reading the resource. *//*from w w w . j a v a 2 s .co m*/ public static Collection<Object[]> loadConfigurations() throws Exception { final String connectionLocation = System.getProperty(CONFIG_FILE_LOCATION); final InputStream is; // closed later by DatabaseConfigurationUtil. if (connectionLocation != null) { is = new FileInputStream(connectionLocation); } else { is = DatabaseTestUtil.class.getClassLoader().getResourceAsStream(CONFIGURATION_FILE); } final Map<String, DatabaseConfiguration> configs = DatabaseConfigurationUtil.from(is) .filter(instancesToTest()); return FluentIterable.from(configs.values()).transform(new Function<DatabaseConfiguration, Object[]>() { @Override public Object[] apply(DatabaseConfiguration input) { return new Object[] { input }; } }).toList(); }
From source file:com.ponysdk.core.export.util.PropertyUtil.java
public static String getProperty(final Object bean, final String property) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Object propertyValue = NA;//from ww w . j a va 2s . co m if (property != null) { final String[] tokens = property.split("\\."); propertyValue = getPropertyValue(bean, tokens[0]); for (int i = 1; i < tokens.length; i++) { if (tokens[i].equals("toString")) { propertyValue = propertyValue.toString(); } else if (PropertyUtils.isReadable(propertyValue, tokens[i])) { propertyValue = PropertyUtils.getProperty(propertyValue, tokens[i]); } else { if (propertyValue instanceof List<?>) { final List<?> propertyList = (List<?>) propertyValue; final List<Object> values = new ArrayList<>(); for (final Object object : propertyList) { values.add(getPropertyValue(object, tokens[i])); } if (values.isEmpty()) propertyValue = NA; else propertyValue = values; } else if (propertyValue instanceof Map<?, ?>) { final Map<?, ?> propertyMap = (Map<?, ?>) propertyValue; final List<Object> values = new ArrayList<>(); for (final Object object : propertyMap.values()) { values.add(getPropertyValue(object, tokens[i])); } propertyValue = values; } else { propertyValue = NA; } } } } return String.valueOf(propertyValue == null ? NA : propertyValue); }
From source file:ddf.catalog.impl.operations.OverrideAttributesSupport.java
public static void applyAttributeOverridesToMetacardMap(Map<String, Serializable> attributeOverrideMap, Map<String, Metacard> metacardMap) { if (MapUtils.isEmpty(attributeOverrideMap) || MapUtils.isEmpty(metacardMap)) { return;// w ww . jav a 2 s .c om } metacardMap.values() .forEach(metacard -> attributeOverrideMap.keySet().stream() .map(attributeName -> metacard.getMetacardType().getAttributeDescriptor(attributeName)) .filter(Objects::nonNull) .map(ad -> overrideAttributeValue(ad, attributeOverrideMap.get(ad.getName()))) .filter(Objects::nonNull).forEach(metacard::setAttribute)); }
From source file:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java
private static int getNumberOfUsages(Map<ProjectIdentifier, List<Usage>> usages) { return usages.values().stream().mapToInt(Collection::size).sum(); }
From source file:com.expressui.core.util.SpringApplicationContext.java
/** * Finds all beans of a given type in the application context. * * @param type type to search for//from w w w . ja v a 2 s. co m * @param <T> type to query * @return set of all beans of a given type */ public static <T> Set<T> getBeansByType(Class<T> type) { Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, type); return new HashSet(beans.values()); }
From source file:com.microsoft.azure.shortcuts.resources.samples.ProvidersSample.java
public static void test(Subscription subscription) throws Exception { // List provider namespaces Map<String, Provider> providers = subscription.providers().asMap(); System.out//from ww w . ja v a 2s . c o m .println(String.format("Provider namespaces: %s\t", StringUtils.join(providers.keySet(), "\n\t"))); // List providers for (Provider provider : providers.values()) { System.out.println(provider.id() + " - " + provider.registrationState()); } if (providers.size() > 0) { // Get information about a specific provider Provider provider = subscription.providers("microsoft.classicstorage"); System.out.println(String.format( "Found provider: %s\n" + "\tRegistration State: %s\n" + "\tAPI versions for resource types:", provider.id(), provider.registrationState())); for (ResourceType t : provider.resourceTypes().values()) { System.out.println(String.format("\t\t%s: %s", t.id(), StringUtils.join(t.apiVersions(), ", "))); } // Get latest API version for a specific resource type String resourceType = "storageAccounts"; System.out.println(String.format("\n\t\tLatest version for type %s: %s", resourceType, provider.resourceTypes().get(resourceType).latestApiVersion())); // Get latest API version for a specific resource type - shortcut System.out.println(String.format("\n\t\tLatest version for type %s: %s", resourceType, provider.resourceTypes(resourceType).latestApiVersion())); } }