本文整理了Java中java.util.LinkedHashMap.putIfAbsent()
方法的一些代码示例,展示了LinkedHashMap.putIfAbsent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedHashMap.putIfAbsent()
方法的具体详情如下:
包路径:java.util.LinkedHashMap
类名称:LinkedHashMap
方法名:putIfAbsent
暂无
代码示例来源:origin: spring-projects/spring-framework
@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);
}
代码示例来源:origin: apache/storm
public synchronized TopologyMetaData get(final Map<String, Object> conf, final String topologyId, final AdvancedFSOps ops,
String stormRoot) {
//Only go off of the topology id for now.
TopologyMetaData dl = _cache.get(topologyId);
if (dl == null) {
_cache.putIfAbsent(topologyId, new TopologyMetaData(conf, topologyId, ops, stormRoot));
dl = _cache.get(topologyId);
}
return dl;
}
代码示例来源:origin: org.springframework/spring-core
@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);
}
代码示例来源:origin: prestodb/presto
Symbol symbol = subPlan.translate(item.getSortKey());
orderings.putIfAbsent(symbol, toSortOrder(item));
代码示例来源:origin: com.ca.apim.gateway/gateway-export-plugin
@Override
public synchronized Object putIfAbsent(Object key, Object value) {
return propertyMap.putIfAbsent(key, value);
}
代码示例来源:origin: org.opencb.biodata/biodata-tools
/**
* Adds Sample names to the sample name set.
* Samples names are used to validate the completeness of a variant call.
* If a sample is not seen in the merged variant, the sample will be added as the registered default value.
* The default values are retrieved by {@link #getDefaultValue(String)} and set to {@link #DEFAULT_MISSING_GT} for GT_KEY.
*
* @param sampleNames Collection of sample names.
*/
public void addExpectedSamples(Collection<String> sampleNames) {
sampleNames.forEach(sample -> expectedSamplesPosition.putIfAbsent(sample, expectedSamplesPosition.size()));
}
代码示例来源:origin: org.ballerinalang/ballerina-core
/**
* Create a collection of JSON nodes which has similary key names.
*
* @param rootMap Map of key and node list pairs
* @param key Key of the JSON nodes
* @param node JSON node to be added
*/
private static void addToRootMap(LinkedHashMap<String, ArrayList<BRefType<?>>> rootMap, String key,
BRefType<?> node) {
rootMap.putIfAbsent(key, new ArrayList<>());
rootMap.get(key).add(node);
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-nodemanager
public synchronized void addFpga(String type, List<FpgaDevice> list) {
availableFpga.putIfAbsent(type, new LinkedList<>());
for (FpgaDevice device : list) {
if (!allowedFpgas.contains(device)) {
allowedFpgas.add(device);
availableFpga.get(type).add(device);
}
}
LOG.info("Add a list of FPGA Devices: " + list);
}
代码示例来源:origin: HuygensING/timbuctoo
public void addNode(Vertex vertex, String entityTypeName) {
try {
nodeIndex.putIfAbsent(new Node(vertex, entityTypeName), nodeIndex.size());
} catch (IOException e) {
LOG.error("Node not added because " + e.getMessage());
}
}
代码示例来源:origin: archerfeel/awacs
public CallElement callSub(CallElement callee) {
CallElement associated = subElements.putIfAbsent(callee.id(), callee);
if (associated != null) {
associated.callCounter++;
return associated;
}
return callee;
}
代码示例来源:origin: freeplane/freeplane
public V computeIfAbsent(K key, Supplier<? extends V> supplier) {
readLock.lock();
try {
V value = cache.get(key);
if (null != value) {
return value;
}
} finally {
readLock.unlock();
}
V value = supplier.get();
writeLock.lock();
try {
V oldValue = cache.putIfAbsent(key, value);
return null != oldValue ? oldValue : value;
} finally {
writeLock.unlock();
}
}
代码示例来源:origin: anba/es6draft
void notePrivateName(IdentifierName privateName) {
String description = privateName.getName();
if (!privateNames.contains(description)) {
undeclaredPrivateNames.putIfAbsent(description, privateName);
}
}
代码示例来源:origin: anba/es6draft
private ClassParseContext restoreClassContext() {
ClassParseContext current = classParseContext;
ClassParseContext parent = current.parent;
// Add all undeclared names to the parent class context.
LinkedHashMap<String, IdentifierName> undeclaredPrivateNames = current.undeclaredPrivateNames;
if (!undeclaredPrivateNames.isEmpty()) {
HashSet<String> declaredNames = current.privateNames;
LinkedHashMap<String, IdentifierName> parentUndeclaredPrivateNames = parent.undeclaredPrivateNames;
undeclaredPrivateNames.forEach((n, id) -> {
if (!declaredNames.contains(n)) {
parentUndeclaredPrivateNames.putIfAbsent(n, id);
}
});
}
return classParseContext = parent;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
@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);
}
代码示例来源:origin: qala-io/datagen
public static void logCurrentSeeds(ExtensionContext context) {
LinkedHashMap<String, Long> seedStrings = new LinkedHashMap<>();
while(context != null) {
Long seed = getCurrentLevelSeedFromStore(context);
Optional<Method> testMethod = context.getTestMethod();
Optional<Class<?>> testClass = context.getTestClass();
if(testMethod.isPresent()) seedStrings.putIfAbsent(testMethod.get().getName(), seed);
else testClass.ifPresent((c)->seedStrings.put(c.getSimpleName(), seed));
context = context.getParent().isPresent() ? context.getParent().get() : null;
}
StringBuilder logLine = new StringBuilder();
for(Map.Entry<String, Long> seed: seedStrings.entrySet()) {
logLine.append(" ").append(seed.getKey()).append("[").append(seed.getValue()).append("]");
}
if(logLine.length() != 0) LOG.info("Random Seeds: {}", logLine);
}
代码示例来源:origin: SonarSonic/Calculator
public void addInfo(Category category, ItemStack stack, String info, Object... objs) {
if (stack == null) {
return;
}
try {
this.info.putIfAbsent(category, new ArrayList<>());
ItemStack[] stacks = new ItemStack[objs.length];
int pos = 0;
for (Object obj : objs) {
stacks[pos] = ItemStackHelper.getOrCreateStack(obj);
pos++;
}
this.info.get(category).add(new ItemInfo(category, stack, info, stacks));
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: baratine/baratine
private static void getMethods(LinkedHashMap<String,Method> map,
Class cls,
boolean isRecursive)
{
LinkedHashMap<String,Method> currentMap = new LinkedHashMap<String,Method>();
Method []methods = cls.getDeclaredMethods();
StringBuilder sb = new StringBuilder();
for (Method m : methods) {
int modifiers = m.getModifiers();
if (Modifier.isStatic(modifiers)) {
}
else if (Modifier.isPublic(modifiers)) {
methodToString(sb, m, false);
currentMap.put(sb.toString(), m);
sb.setLength(0);
}
}
for (Map.Entry<String,Method> entry : currentMap.entrySet()) {
map.putIfAbsent(entry.getKey(), entry.getValue());
}
Class parent = cls.getSuperclass();
if (isRecursive && parent != null && parent != Object.class) {
getMethods(map, parent, true);
}
}
代码示例来源:origin: anba/es6draft
map.putIfAbsent(code, minor);
代码示例来源:origin: kiegroup/appformer
@Override
public Supplier<JGitFileSystem> putIfAbsent(String key, Supplier<JGitFileSystem> value) {
Supplier<JGitFileSystem> jGitFileSystemSupplier = super.putIfAbsent(key, value);
if (size() > config.getJgitFileSystemsInstancesCache()) {
fitListToCacheSize();
}
return jGitFileSystemSupplier;
}
代码示例来源:origin: org.ballerinalang/ballerina-core
rootMap.putIfAbsent(key, new ArrayList<>());
rootMap.get(key).add(element);
内容来源于网络,如有侵权,请联系作者删除!