@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); }
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; }
@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); }
Symbol symbol = subPlan.translate(item.getSortKey()); orderings.putIfAbsent(symbol, toSortOrder(item));
@Override public synchronized Object putIfAbsent(Object key, Object value) { return propertyMap.putIfAbsent(key, value); }
/** * 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())); }
/** * 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); }
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); }
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()); } }
public CallElement callSub(CallElement callee) { CallElement associated = subElements.putIfAbsent(callee.id(), callee); if (associated != null) { associated.callCounter++; return associated; } return callee; }
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(); } }
void notePrivateName(IdentifierName privateName) { String description = privateName.getName(); if (!privateNames.contains(description)) { undeclaredPrivateNames.putIfAbsent(description, privateName); } }
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; }
@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); }
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); }
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(); } }
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); } }
map.putIfAbsent(code, minor);
@Override public Supplier<JGitFileSystem> putIfAbsent(String key, Supplier<JGitFileSystem> value) { Supplier<JGitFileSystem> jGitFileSystemSupplier = super.putIfAbsent(key, value); if (size() > config.getJgitFileSystemsInstancesCache()) { fitListToCacheSize(); } return jGitFileSystemSupplier; }
rootMap.putIfAbsent(key, new ArrayList<>()); rootMap.get(key).add(element);