List of usage examples for java.util Map values
Collection<V> values();
From source file:cognition.pipeline.Main.java
/** * Finds the correct command processor for the given command and executes it. * @param cmd Commands given from the command line */// w w w . j a va 2 s. co m private static void processCommands(CommandLine cmd) { Map<String, CommandProcessor> commands = context.getBeansOfType(CommandProcessor.class); for (CommandProcessor commandProcessor : commands.values()) { if (commandProcessor.isResponsibleFor(cmd)) { commandProcessor.process(cmd); return; } } logger.error("No valid command was given."); CommandHelper.printHelp(); }
From source file:eu.esdihumboldt.hale.io.wfs.ui.KVPUtil.java
/** * Add a new prefix./*from w w w. ja v a2 s . c o m*/ * * @param candidate the prefix candidate * @param namespace the namespace to be associated to the prefix * @param namespaces the current namespaces mapped to prefixes * @return the prefix to use */ private static String addPrefix(String candidate, final String namespace, final Map<String, String> namespaces) { int num = 1; while (namespaces.values().contains(candidate)) { candidate = "ns" + num; num++; } namespaces.put(namespace, candidate); return candidate; }
From source file:com.liferay.apio.architect.internal.body.MultipartToBodyConverter.java
private static <T> Map<String, List<T>> _flattenMap(Map<String, Map<Integer, T>> indexedValueLists) { Set<Entry<String, Map<Integer, T>>> entries = indexedValueLists.entrySet(); Stream<Entry<String, Map<Integer, T>>> stream = entries.stream(); return stream.collect(Collectors.toMap(Entry::getKey, v -> { Map<Integer, T> map = v.getValue(); return new ArrayList<>(map.values()); }));/*from w w w . j av a 2 s . co m*/ }
From source file:com.excilys.ebi.spring.dbunit.utils.ApplicationContextUtils.java
public static <T> T getOptionalUniqueBeanOfType(ApplicationContext applicationContext, Class<T> type) { Map<String, T> configs = applicationContext.getBeansOfType(type); isTrue(configs.size() <= 1, "found more than one bean in the applicationContext"); return configs.size() == 1 ? configs.values().iterator().next() : null; }
From source file:com.autentia.intra.util.HibernateUtil.java
/** * Fully evict an object (including its related objects) from Hibernate cache. * This method is nececessary since HibernateSession.evict() does not evict * related objects, only the main passed instance. Hibernate can be configured * with cascade="evict" to evict the full object, but we prefer to do it * programatically better than by configuration, which can lead to more problems. * * @param dto/*from www . jav a 2s . c o m*/ */ public static void evictFullObject(Object dto) { Session s = currentSession(); s.evict(dto); try { Map props = BeanUtilsBean.getInstance().getPropertyUtils().describe(dto); Collection vals = props.values(); for (Object val : vals) { if (val instanceof ITransferObject) { s.evict(val); } } } catch (Exception e) { log.error("evictFullObject - exception", e); } }
From source file:com.microsoft.azure.shortcuts.resources.samples.PublicIpAddressesSample.java
public static void test(Subscription subscription) throws Exception { String newPublicIpAddressName = "pip" + String.valueOf(System.currentTimeMillis()); // Listing all public IP addresses Map<String, PublicIpAddress> pips = subscription.publicIpAddresses().asMap(); System.out.println("Public IP addresses:"); for (PublicIpAddress pip : pips.values()) { printPIP(pip);/*from w w w . j ava2 s . co m*/ } // Create a public IP address in a default new group PublicIpAddress pipMinimal = subscription.publicIpAddresses().define(newPublicIpAddressName) .withRegion(Region.US_WEST).withNewResourceGroup().create(); // Get info about a specific PIP using its group and name pipMinimal = subscription.publicIpAddresses(pipMinimal.id()); pipMinimal = subscription.publicIpAddresses().get(pipMinimal.id()); String groupNameCreated = pipMinimal.resourceGroup(); printPIP(pipMinimal); // More detailed PIP definition PublicIpAddress pip = subscription.publicIpAddresses().define(newPublicIpAddressName + "2") .withRegion(Region.US_WEST).withExistingResourceGroup(pipMinimal.resourceGroup()) .withLeafDomainLabel("hellomarcins").withStaticIp().withTag("hello", "world").create(); // Listing PIPs in a specific resource group pips = subscription.publicIpAddresses().asMap(pipMinimal.resourceGroup()); System.out.println(String.format("PIP ids in group '%s': \n\t%s", pipMinimal.resourceGroup(), StringUtils.join(pips.keySet(), ",\n\t"))); // Get info about a specific PIP using its resource ID pip = subscription.publicIpAddresses(pip.resourceGroup(), pip.name()); printPIP(pip); // Delete the PIP pipMinimal.delete(); pip.delete(); // Delete the auto-created group subscription.resourceGroups(groupNameCreated).delete(); }
From source file:com.braffdev.server.core.container.injection.DependencyInjector.java
/** * Injects all suitable dependencies to the instances located in the <code>InstanceRegistry</code> of the given container. * * @param container the container./*from ww w . ja va2 s . c om*/ */ public static void inject(Container container) { Registry<Object> instanceRegistry = container.getInstanceRegistry(); Map<String, Object> instances = instanceRegistry.getMap(); Iterator<Object> iterator = instances.values().iterator(); while (iterator.hasNext()) { DependencyInjector.inject(iterator.next(), container); } }
From source file:com.openmeap.model.ModelTestUtils.java
static public void createModel(EntityManager em) { if (em == null) { em = createEntityManager();//from w w w.jav a 2 s .co m } try { Map<String, Map<String, ? extends ModelEntity>> modelBeans = (Map<String, Map<String, ? extends ModelEntity>>) ModelTestUtils .newModelBeans().getBean("mockModel"); // we need to set all (except the Device.uuid) pk's to null, // so the entity manager doesn't flip out, thinking we've passed it // a detached entity for persistence. for (Map.Entry<String, Map<String, ? extends ModelEntity>> classes : modelBeans.entrySet()) for (ModelEntity member : classes.getValue().values()) if (!(member instanceof ApplicationInstallation)) member.setPk(null); em.getTransaction().begin(); for (String className : new String[] { "GlobalSettings", "Application", "ApplicationArchive", "ApplicationVersion", "Deployment", "ApplicationInstallation" }) { Map<String, ? extends ModelEntity> members = modelBeans.get(className); for (ModelEntity member : members.values()) { if (className.equals("Application")) { ((Application) member).setDeployments(null); } em.persist(member); em.flush(); } } em.getTransaction().commit(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.mmj.app.lucene.search.build.SearchBuilder.java
public static VersionableSearch<?, ?> getSearch(SearchTypeEnum searchType) { try {//from w w w .jav a 2s . c o m @SuppressWarnings("rawtypes") Map beansOfType = SpringContextAware.getBeansOfType(searchType.getType()); for (Object object : beansOfType.values()) { return (VersionableSearch<?, ?>) object; } } catch (Exception e) { throw new SolrUnSupportException( String.format("Not Support SearchType ?%s", searchType.getDesc())); } return null; }
From source file:com.microsoft.azure.shortcuts.resources.samples.ResourcesSample.java
public static void test(Subscription subscription) throws Exception { // Listing all resource names Map<String, Resource> resources = subscription.resources().asMap(); System.out.println(String.format("Resource ids: %s\n\t", StringUtils.join(resources.keySet(), ",\n\t"))); // Listing resources in a specific group String groupName = "azchat"; Map<String, Resource> resources2 = subscription.resources().asMap(groupName); System.out.println("Resources inside group '" + groupName + "':"); for (Resource resource : resources2.values()) { printResource(resource);// w w w .j ava2s . c om } // Getting information about a specific resource based on ID Resource resource = subscription.resources( "/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/javasampleresourcegroup/providers/Microsoft.Storage/storageAccounts/javastojzgsg"); printResource(resource); // Getting information about a specific resource based on name, type, provider and group resource = subscription.resources().get(resource.name(), resource.type(), resource.provider(), resource.resourceGroup()); printResource(resource); // Delete a resource System.out.println(String.format("Deleting resource '%s' of type '%s' by provider '%s' in group '%s'", resource.name(), resource.type(), resource.provider(), resource.resourceGroup())); resource.delete(); // Delete a resource based on its ID String resourceToDelete = "ThisMustFail"; System.out.println("Deleting resource " + resourceToDelete); subscription.resources().delete(resourceToDelete); }