public StringInterningAmazonInfoBuilder withMetadata(HashMap<String, String> metadata) { this.metadata = metadata; if (metadata.isEmpty()) { return this; } for (Map.Entry<String, String> entry : metadata.entrySet()) { String key = entry.getKey().intern(); if (VALUE_INTERN_KEYS.containsKey(key)) { entry.setValue(StringCache.intern(entry.getValue())); } } return this; }
public FindBrokerResult findBrokerAddressInSubscribe( final String brokerName, final long brokerId, final boolean onlyThisBroker ) { String brokerAddr = null; boolean slave = false; boolean found = false; HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName); if (map != null && !map.isEmpty()) { brokerAddr = map.get(brokerId); slave = brokerId != MixAll.MASTER_ID; found = brokerAddr != null; if (!found && !onlyThisBroker) { Entry<Long, String> entry = map.entrySet().iterator().next(); brokerAddr = entry.getValue(); slave = entry.getKey() != MixAll.MASTER_ID; found = true; } } if (found) { return new FindBrokerResult(brokerAddr, slave, findBrokerVersion(brokerName, brokerAddr)); } return null; }
/** * Get the class id, or null if not found. * * @param clazz the class * @return the class id or null */ static Integer getCommonClassId(Class<?> clazz) { HashMap<Class<?>, Integer> map = COMMON_CLASSES_MAP; if (map.isEmpty()) { // lazy initialization for (int i = 0, size = COMMON_CLASSES.length; i < size; i++) { COMMON_CLASSES_MAP.put(COMMON_CLASSES[i], i); } } return map.get(clazz); }
if (rsLogTimestampMap == null || rsLogTimestampMap.isEmpty()) { return null; HashMap<String, HashMap<TableName, Long>> rsLogTimestampMapByRS = new HashMap<>(); for (Entry<TableName, HashMap<String, Long>> tableEntry : rsLogTimestampMap.entrySet()) { TableName table = tableEntry.getKey(); HashMap<String, Long> rsLogTimestamp = tableEntry.getValue(); for (Entry<String, Long> rsEntry : rsLogTimestamp.entrySet()) { String rs = rsEntry.getKey(); Long ts = rsEntry.getValue(); if (!rsLogTimestampMapByRS.containsKey(rs)) { rsLogTimestampMapByRS.put(rs, new HashMap<>()); rsLogTimestampMapByRS.get(rs).put(table, ts); } else { rsLogTimestampMapByRS.get(rs).put(table, ts); for (Entry<String, HashMap<TableName, Long>> entry : rsLogTimestampMapByRS.entrySet()) { String rs = entry.getKey(); rsLogTimestampMins.put(rs, BackupUtils.getMinValue(entry.getValue()));
public static AnnotationMap merge(AnnotationMap primary, AnnotationMap secondary) { if (primary == null || primary._annotations == null || primary._annotations.isEmpty()) { return secondary; } if (secondary == null || secondary._annotations == null || secondary._annotations.isEmpty()) { return primary; } HashMap<Class<?>,Annotation> annotations = new HashMap<Class<?>,Annotation>(); // add secondary ones first for (Annotation ann : secondary._annotations.values()) { annotations.put(ann.annotationType(), ann); } // to be overridden by primary ones for (Annotation ann : primary._annotations.values()) { annotations.put(ann.annotationType(), ann); } return new AnnotationMap(annotations); }
/** * Get current model. * @param forDeck If true, it tries to get the deck specified in deck by mid, otherwise or if the former is not * found, it uses the configuration`s field curModel. * @return The JSONObject of the model, or null if not found in the deck and in the configuration. */ public JSONObject current(boolean forDeck) { JSONObject m = null; if (forDeck) { m = get(mCol.getDecks().current().optLong("mid", -1)); } if (m == null) { m = get(mCol.getConf().optLong("curModel", -1)); } if (m == null) { if (!mModels.isEmpty()) { m = mModels.values().iterator().next(); } } return m; }
@Override public HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) { HashMap<Integer, T_Sess> sessions = getCache(userDevice).sessions.get(contact); if (sessions == null) { sessions = new HashMap<>(); getCache(userDevice).sessions.put(contact, sessions); } if (sessions.isEmpty() && persistent != null) { sessions.putAll(persistent.loadAllRawSessionsOf(userDevice, contact)); } return new HashMap<>(sessions); }
@Override public boolean visitFile(@NotNull VirtualFile file) { final HashMap<IgnoreEntry, Pattern> current = ContainerUtil.newHashMap(getCurrentValue()); if (current.isEmpty()) { return false; } final String path = Utils.getRelativePath(root, file); if (path == null || Utils.isVcsDirectory(file)) { return false; } for (Map.Entry<IgnoreEntry, Pattern> item : current.entrySet()) { final Pattern value = item.getValue(); boolean matches = false; if (value == null || matcher.match(value, path)) { matches = true; result.get(item.getKey()).add(file); } if (includeNested && matches) { current.put(item.getKey(), null); } } setValueForChildren(current); return true; } };
/** * For each entry that is not dirty (all we did was read it) decrement its refcount (so it can be * evicted as we apply our writes) and remove it from entryMods (so we don't keep iterating over * it and se we don't try to clean it up again later). */ void cleanupNonDirtyEntries(InternalRegion r) { if (!this.entryMods.isEmpty()) { Iterator it = this.entryMods.entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); // Object eKey = me.getKey(); TXEntryState txes = (TXEntryState) me.getValue(); if (txes.cleanupNonDirty(r)) { it.remove(); } } } }
/** * Nullable * * @return HashMap<String, String> */ public HashMap<String, String> getPackagePropertiesIfPresent() { if (!packageProperties.isEmpty()) { return packageProperties; } String property = metaContentMap.get(ShareConstants.PACKAGE_META_FILE); if (property == null) { return null; } String[] lines = property.split("\n"); for (final String line : lines) { if (line == null || line.length() <= 0) { continue; } //it is comment if (line.startsWith("#")) { continue; } final String[] kv = line.split("=", 2); if (kv == null || kv.length < 2) { continue; } packageProperties.put(kv[0].trim(), kv[1].trim()); } return packageProperties; }
if (serverToBucketsMap.get(server) == null) { HashSet<Integer> bucketSet = new HashSet<Integer>(); bucketSet.add(bucketId); serverToBucketsMap.put(server, bucketSet); } else { HashSet<Integer> bucketSet = serverToBucketsMap.get(server); bucketSet.add(bucketId); serverToBucketsMap.put(server, bucketSet); if (serverToBucketsMap.isEmpty()) { return null; } else { (ServerLocation) serverToBucketsMap.keySet().toArray()[rand.nextInt(size)]; HashSet<Integer> bucketSet = serverToBucketsMap.get(randomFirstServer); if (isDebugEnabled) { logger.debug( prunedServerToBucketsMap.put(randomFirstServer, bucketSet); serverToBucketsMap.remove(randomFirstServer); ServerLocation server = findNextServer(serverToBucketsMap.entrySet(), currentBucketSet); if (server == null) { break;
public static AnnotationMap merge(AnnotationMap primary, AnnotationMap secondary) { if (primary == null || primary._annotations == null || primary._annotations.isEmpty()) { return secondary; } if (secondary == null || secondary._annotations == null || secondary._annotations.isEmpty()) { return primary; } HashMap<Class<?>,Annotation> annotations = new HashMap<Class<?>,Annotation>(); // add secondary ones first for (Annotation ann : secondary._annotations.values()) { annotations.put(ann.annotationType(), ann); } // to be overridden by primary ones for (Annotation ann : primary._annotations.values()) { annotations.put(ann.annotationType(), ann); } return new AnnotationMap(annotations); }
private boolean getPickedUp(GlowPlayer player) { // todo: fire PlayerPickupItemEvent in a way that allows for 'remaining' calculations HashMap<Integer, ItemStack> map = player.getInventory().addItem(getItemStack()); player .updateInventory(); // workaround for player editing slot & it immediately being // filled again if (!map.isEmpty()) { setItemStack(map.values().iterator().next()); return false; } else { CollectItemMessage message = new CollectItemMessage(getEntityId(), player.getEntityId(), getItemStack().getAmount()); world.playSound(location, Sound.ENTITY_ITEM_PICKUP, 0.3f, (float) (1 + Math.random())); world.getRawPlayers().stream().filter(other -> other.canSeeEntity(this)) .forEach(other -> other.getSession().send(message)); remove(); return true; } }
public String[][] getHeaders(Object value, Operation operation) throws ServiceException { Response delegate = (Response) value; HashMap map = new HashMap(); if (delegate.getContentDisposition() != null) { map.put("Content-Disposition", delegate.getContentDisposition()); } HashMap m = delegate.getResponseHeaders(); if (m != null && !m.isEmpty()) { map.putAll(m); } if (map == null || map.isEmpty()) return null; String[][] headers = new String[map.size()][2]; List keys = new ArrayList(map.keySet()); for (int i = 0; i < headers.length; i++) { headers[i][0] = (String) keys.get(i); headers[i][1] = (String) map.get(keys.get(i)); } return headers; }
for (Map.Entry<String, TableScanOperator> topOpEntry : topOps.entrySet()) { if (topOpEntry.getValue() == tso) { String newAlias = topOpEntry.getKey(); if (!newAlias.equals(alias)) { joinAliases.set(index, newAlias); baseBigAlias = newAlias; aliasToNewAliasMap.put(alias, newAlias); alias = newAlias; context.setBaseBigAlias(baseBigAlias); context.setBigTablePartitioned(bigTablePartitioned); if (!aliasToNewAliasMap.isEmpty()) { context.setAliasToNewAliasMap(aliasToNewAliasMap);