List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:de.ingrid.admin.Utils.java
public static Set<String> getUnionOfDatatypes(Map<String, String[]> datatypesOfIndex) { Set<String> allUniqueTypes = new LinkedHashSet<>(); if (datatypesOfIndex != null) { Set<String> indices = datatypesOfIndex.keySet(); for (String index : indices) { allUniqueTypes.addAll(Arrays.asList(datatypesOfIndex.get(index))); }/*w w w . j a va2 s. c o m*/ } return allUniqueTypes; }
From source file:com.pieframework.runtime.core.ResourceLoader.java
public static void validate(Map<String, Resource> validation, String componentId) { for (String key : validation.keySet()) { //System.out.println(componentId+" "+key+" "+validation.get(key)); if (validation.get(key) == null) { throw new RuntimeException("Resource:" + key + " is missing for " + componentId); //System.out.println("throwing exception for "+key+" "+componentId); }//ww w. java 2s . c o m } }
From source file:org.web4thejob.orm.ORMUtil.java
public static List<PanelDefinition> getPanelsMatchingTags(Map<String, Object> tags) { Query query = ContextUtil.getEntityFactory().buildQuery(PanelDefinition.class); for (String tag : tags.keySet()) { query.addCriterion(new Path(PanelDefinition.FLD_TAGS), Condition.CN, CoreUtil.buildTagValue(tag, tags.get(tag))); }// w w w.j ava 2 s .com query.addOrderBy(new Path(PanelDefinition.FLD_NAME)); query.setCached(true); List<PanelDefinition> panels = new ArrayList<PanelDefinition>(); for (Entity item : ContextUtil.getDRS().findByQuery(query)) { if (ContextUtil.getSessionContext().hasPanel(((PanelDefinition) item).getBeanId(), org.web4thejob.web.panel.Panel.class)) { panels.add((PanelDefinition) item); } } if (panels.isEmpty()) { Collections.emptyList(); } return panels; }
From source file:cz.jirutka.validator.collection.internal.AnnotationUtils.java
/** * Creates instance (proxy) of the specified annotation with the given * attributes.// www .j a v a 2 s .c o m * * @param annotationType The annotation's class. * @param attributes A map with attribute values for the annotation to be created. * @param <T> The type of the annotation. * * @return An instance of the annotation. * @throws IllegalArgumentException if some attribute has wrong type or * a required attribute is missing. */ public static <T extends Annotation> T createAnnotation(Class<T> annotationType, Map<String, Object> attributes) { // check if given attributes are defined in annotation for (Iterator<String> it = attributes.keySet().iterator(); it.hasNext();) { String name = it.next(); Object value = attributes.get(name); if (value == null) { LOG.warn("Attribute's value must not be null; will be ignored"); it.remove(); continue; } if (!hasAttribute(annotationType, name)) { LOG.warn("Annotation {} does not define attribute: {}; will be ignored", annotationType.getName(), name); it.remove(); continue; } Class<?> attrType = getAttributeType(annotationType, name); Validate.isTrue(isAssignable(value.getClass(), attrType), "Attribute '%s' expects %s, but given: %s (%s)", name, attrType.getName(), value, value.getClass().getName()); } // check if required attributes are given for (Method m : annotationType.getDeclaredMethods()) { Validate.isTrue(attributes.containsKey(m.getName()) || m.getDefaultValue() != null, "Missing required attribute: %s", m.getName()); } AnnotationDescriptor<T> descriptor = AnnotationDescriptor.getInstance(annotationType, attributes); return AnnotationFactory.create(descriptor); }
From source file:org.jetbrains.webdemo.backend.executor.ExecutorUtils.java
private static Path storeFilesInTemporaryDirectory(Map<String, byte[]> files) throws IOException { Path outputDir = Paths.get(BackendSettings.OUTPUT_DIRECTORY, "tmp", String.valueOf(new Random().nextInt())); for (String fileName : files.keySet()) { Path filePath = outputDir.resolve(fileName); filePath.getParent().toFile().mkdirs(); Files.write(filePath, files.get(fileName)); }//from www .j a v a2s .co m return outputDir; }
From source file:com.sugarcrm.candybean.datasource.CsvDataAdapterUnitTest.java
private static void printDataSource(Map<String, DataSource> dataSourceHashMap) { for (String filenameNoExt : dataSourceHashMap.keySet()) { System.out.println(//www . j ava 2 s.co m "CsvDataAdapterTest: printDataSourceData(): dataSource filenameNoExt = " + filenameNoExt); DataSource ds = dataSourceHashMap.get(filenameNoExt); printDataSourceFieldSet(ds); } }
From source file:utils.Utils.java
public static String replaceVariables(String userdataRaw, Map<String, String> variables) { String userdata = userdataRaw; for (String variable : variables.keySet()) { log.debug("Replace " + variable + " with value " + variables.get(variable)); userdata = userdata.replaceAll(Pattern.quote(variable), variables.get(variable)); log.debug("Replaced userdata: " + userdata); //}//from www .j av a 2 s . com } return userdata; }
From source file:com.clustercontrol.platform.collect.QueryExecutor.java
public static <T> List<T> getListWithTimeout(String queryName, Class<T> resultClass, Map<String, Object> parameters) { setStatementTimeout();/*from w w w.j av a 2 s . c o m*/ HinemosEntityManager em = new JpaTransactionManager().getEntityManager(); TypedQuery<T> query = em.createNamedQuery(queryName, resultClass); for (String key : parameters.keySet()) { query.setParameter(key, parameters.get(key)); } List<T> list = query.getResultList(); resetStatementTimeout(); return list; }
From source file:com.kenshoo.freemarker.view.FreeMarkerOnlineView.java
private static List<SelectionOption> toSelectionOptions(Map<String, ?> settingValueMap) { ArrayList<SelectionOption> selectionOptions = new ArrayList<SelectionOption>(settingValueMap.size()); for (String key : settingValueMap.keySet()) { selectionOptions.add(new SelectionOption(key, truncate(key, 25))); }// ww w .ja v a2s . c o m Collections.sort(selectionOptions); return selectionOptions; }
From source file:edu.cornell.mannlib.vitro.webapp.beans.VClassGroup.java
public static void removeEmptyClassGroups(Map groups) { if (groups == null) return;/* w w w . j a va 2s. c o m*/ List keysToRemove = new LinkedList(); Iterator it = groups.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Object grp = groups.get(key); if (grp != null && grp instanceof AbstractCollection) { if (((AbstractCollection) grp).isEmpty()) keysToRemove.add(key); } } it = keysToRemove.iterator(); while (it.hasNext()) { groups.remove(it.next()); } }