@Override public V putIfAbsent(K key, V value) { synchronized (this) { return super.putIfAbsent(key, value); } }
@Override @Nullable public V putIfAbsent(String key, @Nullable V value) { String oldKey = this.caseInsensitiveKeys.putIfAbsent(convertKey(key), key); if (oldKey != null) { return this.targetMap.get(oldKey); } return this.targetMap.putIfAbsent(key, value); }
@Override @Nullable public V computeIfAbsent(String key, Function<? super String, ? extends V> mappingFunction) { String oldKey = this.caseInsensitiveKeys.putIfAbsent(convertKey(key), key); if (oldKey != null) { return this.targetMap.get(oldKey); } return this.targetMap.computeIfAbsent(key, mappingFunction); }
public static FieldGetter getFieldGetter(Object key, Class<?> targetClass, String fieldName) { FieldGetter fieldGetter = fieldGetterCache.get(key); if (fieldGetter == null) { fieldGetter = doGetFieldGetter(targetClass, fieldName); // 已确保不会返回 null fieldGetterCache.putIfAbsent(key, fieldGetter); } return fieldGetter; }
@Override @Nullable public V computeIfAbsent(String key, Function<? super String, ? extends V> mappingFunction) { String oldKey = this.caseInsensitiveKeys.putIfAbsent(convertKey(key), key); if (oldKey != null) { return this.targetMap.get(oldKey); } return this.targetMap.computeIfAbsent(key, mappingFunction); }
@Override @Nullable public V putIfAbsent(String key, @Nullable V value) { String oldKey = this.caseInsensitiveKeys.putIfAbsent(convertKey(key), key); if (oldKey != null) { return this.targetMap.get(oldKey); } return this.targetMap.putIfAbsent(key, value); }
/** * Process multi-word prepositions. */ private static void processMultiwordPreps(SemanticGraph sg) { /* Semgrexes require a graph with a root. */ if (sg.getRoots().isEmpty()) return; HashMap<String, HashSet<Integer>> bigrams = new HashMap<>(); HashMap<String, HashSet<Integer>> trigrams = new HashMap<>(); List<IndexedWord> vertexList = sg.vertexListSorted(); int numWords = vertexList.size(); for (int i = 1; i < numWords; i++) { String bigram = vertexList.get(i-1).value().toLowerCase() + '_' + vertexList.get(i).value().toLowerCase(); bigrams.putIfAbsent(bigram, new HashSet<>()); bigrams.get(bigram).add(vertexList.get(i-1).index()); if (i > 1) { String trigram = vertexList.get(i-2).value().toLowerCase() + '_' + bigram; trigrams.putIfAbsent(trigram, new HashSet<>()); trigrams.get(trigram).add(vertexList.get(i-2).index()); } } /* Simple two-word prepositions. */ processSimple2WP(sg, bigrams); /* More complex two-word prepositions in which the first * preposition is the head of the prepositional phrase. */ processComplex2WP(sg, bigrams); /* Process three-word prepositions. */ process3WP(sg, trigrams); }
public SharedMethodInfo getSharedMethodInfo(String methodName, Object[] argValues) { Class<?>[] argTypes = MethodKit.getArgTypes(argValues); Long key = getSharedMethodKey(methodName, argTypes); SharedMethodInfo method = methodCache.get(key); if (method == null) { method = doGetSharedMethodInfo(methodName, argTypes); if (method != null) { methodCache.putIfAbsent(key, method); } // shared method 不支持 null safe,不缓存: methodCache.putIfAbsent(key, Void.class) } return method; }
@Override public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException { TopicMessageStore rc = (TopicMessageStore) storeCache.get(destination); if (rc == null) { TopicMessageStore store = transactionStore.proxy(new JDBCTopicMessageStore(this, getAdapter(), wireFormat, destination, audit)); rc = (TopicMessageStore) storeCache.putIfAbsent(destination, store); if (rc == null) { rc = store; } } return rc; }
@Override public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException { MessageStore rc = storeCache.get(destination); if (rc == null) { MessageStore store = transactionStore.proxy(new JDBCMessageStore(this, getAdapter(), wireFormat, destination, audit)); rc = storeCache.putIfAbsent(destination, store); if (rc == null) { rc = store; } } return rc; }
private KsqlRestConfig buildConfig() { final HashMap<String, Object> config = new HashMap<>(baseConfig); config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers.get()); config.putIfAbsent(KsqlRestConfig.LISTENERS_CONFIG, "http://localhost:0,https://localhost:0"); return new KsqlRestConfig(config); }
private List<Map<String, String>> getScopes(ArrayList<String> scopes) { List<Map<String, String>> result = new ArrayList<Map<String, String>>(); for (String scope : scopes) { HashMap<String, String> map = new HashMap<String, String>(); String code = SCOPE_PREFIX + scope; map.put("code", code); Optional<ScimGroup> group = groupProvisioning.query(String.format("displayName eq \"%s\"", scope), IdentityZoneHolder.get().getId()).stream().findFirst(); group.ifPresent(g -> { String description = g.getDescription(); if (StringUtils.hasText(description)) { map.put("text", description); } }); map.putIfAbsent("text", scope); result.add(map); } Collections.sort(result, (map1, map2) -> { String code1 = map1.get("code"); String code2 = map2.get("code"); int i; if (0 != (i = codeIsPasswordOrOpenId(code2) - codeIsPasswordOrOpenId(code1))) { return i; } return code1.compareTo(code2); }); return result; }
/** {@inheritDoc} */ @Override public void collectGridNodeData(DiscoveryDataBag dataBag) { if (dataBag.isJoiningNodeClient() || dataBag.commonDataCollectedFor(ENCRYPTION_MGR.ordinal())) return; HashMap<Integer, byte[]> knownEncKeys = knownEncryptionKeys(); HashMap<Integer, byte[]> newKeys = newEncryptionKeys(knownEncKeys == null ? Collections.EMPTY_SET : knownEncKeys.keySet()); if (knownEncKeys == null) knownEncKeys = newKeys; else if (newKeys != null) { for (Map.Entry<Integer, byte[]> entry : newKeys.entrySet()) { byte[] old = knownEncKeys.putIfAbsent(entry.getKey(), entry.getValue()); assert old == null; } } dataBag.addGridCommonData(ENCRYPTION_MGR.ordinal(), knownEncKeys); }
mappedItem = m_hashMap.putIfAbsent(cacheData, li);
.forEach( (k, v) -> { SeverityLevel existing = combinedSeverities.putIfAbsent(k, v); if (existing != null && !existing.equals(v)) { throw new IllegalArgumentException(
/** * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public String putIfAbsent(String key, String value) { return super.putIfAbsent(key, value); }
/** * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public String putIfAbsent(String key, String value) { return super.putIfAbsent(key, value); }
/** * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public String putIfAbsent(String key, String value) { return super.putIfAbsent(key, value); }
/** * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public String putIfAbsent(String key, String value) { return super.putIfAbsent(key, value); }
/** * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public String putIfAbsent(String key, String value) { return super.putIfAbsent(key, value); }