List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:com.facebook.presto.accumulo.iterators.AbstractBooleanFilter.java
protected static IteratorSetting combineFilters(Class<? extends AbstractBooleanFilter> clazz, int priority, IteratorSetting... configs) {//from www. j a v a 2 s .c o m if (configs == null || configs.length == 0) { throw new IllegalArgumentException("Iterator configs are null or empty"); } Map<String, String> props = new HashMap<>(); for (IteratorSetting cfg : configs) { if (props.containsKey(cfg.getName())) { throw new IllegalArgumentException( "Destination config already has config for filter called " + cfg.getName()); } Map<String, String> propCopy = new HashMap<>(cfg.getOptions()); propCopy.put(FILTER_JAVA_CLASS_NAME, cfg.getIteratorClass()); try { props.put(cfg.getName(), OBJECT_MAPPER.writeValueAsString(propCopy)); } catch (JsonProcessingException e) { throw new IllegalArgumentException("Failed to encode map as json string", e); } } return new IteratorSetting(priority, UUID.randomUUID().toString(), clazz, props); }
From source file:com.qmetry.qaf.automation.util.LocatorUtil.java
public static String getDescription(String locator) { if (JSONUtil.isValidJsonString(locator)) { try {//from w w w .j a v a 2 s . c om Map<String, Object> map = JSONUtil.toMap(locator); return map.containsKey("desc") ? (String) map.get("desc") : map.containsKey("description") ? (String) map.get("description") : (String) map.get("locator"); } catch (JSONException e) { } } return locator; }
From source file:jease.site.Authorizations.java
/** * Returns guarding Access object for given content or null, if content is * not guarded.//from w ww .ja v a2s . c o m */ public static Access[] getGuards(Content content) { if (content == null) { return null; } Map<Content, Access[]> cache = Database.query(accessByContent); if (!cache.containsKey(content)) { List<Access> allGuards = new ArrayList<>(); Access[] accessGuards = content.getGuards(Access.class); if (ArrayUtils.isNotEmpty(accessGuards)) { Collections.addAll(allGuards, accessGuards); } else { Reference[] referenceGuards = content.getGuards(Reference.class); if (ArrayUtils.isNotEmpty(referenceGuards)) { for (Reference reference : referenceGuards) { if (reference.getContent() instanceof Access) { allGuards.add((Access) reference.getContent()); } } } } cache.put(content, allGuards.toArray(new Access[allGuards.size()])); } List<Access> activeGuards = new ArrayList<>(); for (Access access : cache.get(content)) { if (access.isGuarding()) { activeGuards.add(access); } } if (!activeGuards.isEmpty()) { return activeGuards.toArray(new Access[activeGuards.size()]); } else { return getGuards((Content) content.getParent()); } }
From source file:com.formkiq.core.util.Zips.java
/** * Find bytes in zip by name.// ww w . j a va 2 s . com * @param bytes byte[] * @param name {@link String} * @return {@link Optional} * @throws IOException IOException */ public static Optional<byte[]> findInZip(final byte[] bytes, final String name) throws IOException { Map<String, byte[]> map = Zips.extractZipToMap(bytes); if (map.containsKey(name)) { return Optional.of(map.get(name)); } return Optional.empty(); }
From source file:Main.java
public static String[] intersect(String[] arr1, String[] arr2) { Map<String, Boolean> map = new HashMap<String, Boolean>(); LinkedList<String> list = new LinkedList<String>(); for (String str : arr1) { if (!map.containsKey(str)) { map.put(str, Boolean.FALSE); }/*from w w w. j a v a2 s. c om*/ } for (String str : arr2) { if (map.containsKey(str)) { map.put(str, Boolean.TRUE); } } for (Map.Entry<String, Boolean> e : map.entrySet()) { if (e.getValue().equals(Boolean.TRUE)) { list.add(e.getKey()); } } String[] result = {}; return list.toArray(result); }
From source file:com.microsoft.alm.plugin.idea.common.ui.workitem.WorkItemHelper.java
public static String getRelationUrl(@NotNull final WorkItem item, @NotNull final String attributeName, @NotNull final String attributeValue) { final List<WorkItemRelation> relationsList = item.getRelations(); if (relationsList != null) { for (WorkItemRelation relation : relationsList) { final Map<String, Object> attributes = relation.getAttributes(); if (attributes != null && attributes.containsKey(attributeName) && attributeValue.equalsIgnoreCase(attributes.get(attributeName).toString())) { return relation.getUrl(); }/*w ww .j a v a 2 s. co m*/ } } return StringUtils.EMPTY; }
From source file:Main.java
public static <G> Map<String, G> transferRootNameMap(Map<Integer, Integer> rootIdIdMap, Map<Integer, G> idValueMap, G defaultValue) { Map<String, G> rootValueMap = new LinkedHashMap<String, G>(); for (Entry<Integer, Integer> entry : rootIdIdMap.entrySet()) { if (idValueMap.containsKey(entry.getValue())) { rootValueMap.put(entry.getKey().toString(), idValueMap.get(entry.getValue())); } else {//from w ww . jav a2 s .c o m rootValueMap.put(entry.getKey().toString(), defaultValue); } } return rootValueMap; }
From source file:net.eledge.android.europeana.search.model.record.abstracts.Resource.java
public static String[] getPreferred(Map<String, String[]> data, String locale) { if (data != null) { String key = null;//from w w w.ja v a 2s . c om if ((locale != null) && data.containsKey(locale)) { key = locale; } else if (data.containsKey("def")) { key = "def"; } else if (data.containsKey("en")) { key = "en"; } if (key == null) { key = data.keySet().iterator().next(); } return data.get(key); } return null; }
From source file:gemlite.core.support.SyncListenerTool.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void BucketChangeEventOnView(int bucketId, Iterable<?> keys, String regionName, EventStatus status) {//from w w w . j a v a 2 s .c o m GemliteViewContext context = GemliteViewContext.getInstance(); Map<String, Set<String>> regionToView = context.getRegionToView(); if (regionToView.containsKey(regionName)) { Map<String, ViewItem> viewMap = context.getViewContext(); Set<String> itemSet = regionToView.get(regionName); for (String itemName : itemSet) { ViewItem viewItem = viewMap.get(itemName); ViewTool viewTool = viewItem.getViewTool(); if (viewTool != null) { if (status == EventStatus.AfterBucketCreated) viewTool.afterBucketCreated(bucketId, keys); else if (status == EventStatus.AfterBucketRemoved) viewTool.afterBucketRemoved(bucketId, keys); } } } }
From source file:com.mingo.mongo.aggregation.AggregationUtils.java
/** * Added condition for created field.//from ww w. j a v a 2 s . c om * * @param builder {@link BasicDBObjectBuilder} * @param field field * @param parameters parameters */ public static void addBetweenCriteria(BasicDBObjectBuilder builder, String field, Map<String, String> parameters) { BasicDBObjectBuilder createdBuilder = start(); Date startRange = parameters.containsKey(START_DATE) ? convertToDate(parameters.get(START_DATE)) : null; Date endRange = parameters.containsKey(END_DATE) ? addDays(convertToDate(parameters.get(END_DATE)), 1) : null; if (startRange != null) { createdBuilder.add(GT.getMongoName(), startRange); } if (endRange != null) { createdBuilder.add(LT.getMongoName(), endRange); } if (!createdBuilder.isEmpty()) { builder.add(field, createdBuilder.get()); } }