java.util.Hashtable.computeIfAbsent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中java.util.Hashtable.computeIfAbsent()方法的一些代码示例,展示了Hashtable.computeIfAbsent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hashtable.computeIfAbsent()方法的具体详情如下:
包路径:java.util.Hashtable
类名称:Hashtable
方法名:computeIfAbsent

Hashtable.computeIfAbsent介绍

暂无

代码示例

代码示例来源:origin: apache/jena

public static void finishCaching() {
  log.trace("call finishCaching()");
  for (final Entry<String,List<String>> auxIndexesE : auxIndexes.entrySet()) {
    final String tag = auxIndexesE.getKey(); // ex: zh-hans
    final List<String> auxIndexesL = auxIndexesE.getValue();
    log.trace("finishCaching: tag: {}", tag);
    for (final String auxIndexTag : auxIndexesL) { // ex: auxIndexTag: zh-aux-han2pinyin
      log.trace("finishCaching: auxIndexTag: {}", auxIndexTag);
      for (final String searchForTag : searchForTags.get(auxIndexTag)) { // ex: zh-latn-pinyin
        final Hashtable<String,String> res = effectiveFields.computeIfAbsent(tag, x -> new Hashtable<String,String>());
        log.trace("add effectiveField mapping: d:{} + q:{} = e:{}", tag, searchForTag, auxIndexTag);
        res.put(searchForTag, auxIndexTag);
      }
    }
  }
}

代码示例来源:origin: cool.pandora/modeller-fedora

/**
 * @param type Type
 */
private static void storeType(final Type type) {
  final String className = type.getClass().getName();
  final Hashtable<Integer, Type> values;
  synchronized (types) {
    values = types.computeIfAbsent(className, k -> new Hashtable<>());
  }
  values.put(type.getValue(), type);
}

代码示例来源:origin: org.apache.jena/jena-text

public static void finishCaching() {
  log.trace("call finishCaching()");
  for (final Entry<String,List<String>> auxIndexesE : auxIndexes.entrySet()) {
    final String tag = auxIndexesE.getKey(); // ex: zh-hans
    final List<String> auxIndexesL = auxIndexesE.getValue();
    log.trace("finishCaching: tag: {}", tag);
    for (final String auxIndexTag : auxIndexesL) { // ex: auxIndexTag: zh-aux-han2pinyin
      log.trace("finishCaching: auxIndexTag: {}", auxIndexTag);
      for (final String searchForTag : searchForTags.get(auxIndexTag)) { // ex: zh-latn-pinyin
        final Hashtable<String,String> res = effectiveFields.computeIfAbsent(tag, x -> new Hashtable<String,String>());
        log.trace("add effectiveField mapping: d:{} + q:{} = e:{}", tag, searchForTag, auxIndexTag);
        res.put(searchForTag, auxIndexTag);
      }
    }
  }
}

代码示例来源:origin: de.adorsys/hbci4j-adorsys

private Hashtable<String, List<String>> getLowlevelGVs(Document document) {
  Hashtable<String, List<String>> result = new Hashtable<>();
  Element gvlist = document.getElementById("GV");
  NodeList gvs = gvlist.getChildNodes();
  int len = gvs.getLength();
  StringBuilder type = new StringBuilder();
  for (int i = 0; i < len; i++) {
    Node gvref = gvs.item(i);
    if (gvref.getNodeType() == Node.ELEMENT_NODE) {
      type.setLength(0);
      type.append(((Element) gvref).getAttribute("type"));
      int pos = type.length() - 1;
      char ch;
      while ((ch = type.charAt(pos)) >= '0' && ch <= '9') {
        pos--;
      }
      String gvname = type.substring(0, pos + 1);
      List<String> entry = result.computeIfAbsent(gvname, k -> new ArrayList<>());
      entry.add(type.substring(pos + 1));
    }
  }
  return result;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    V oldValue = get(key);
    if (oldValue == null) {
      V newValue = mappingFunction.apply(key);
      if (newValue != null) {
        put(key, newValue);
      }
      return newValue;
    }
    return oldValue;
  }
  return getDelegate().computeIfAbsent(key, mappingFunction);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

@Override
public synchronized V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    V oldValue = get(key);
    if (oldValue == null) {
      V newValue = mappingFunction.apply(key);
      if (newValue != null) {
        put(key, newValue);
      }
      return newValue;
    }
    return oldValue;
  }
  return getDelegate().computeIfAbsent(key, mappingFunction);
}

代码示例来源:origin: octo-online/reactive-audit

@Test(expected = ReactiveAuditException.class)
public void computeIfAbsent()
{
  ReactiveAudit.off.commit();
  Hashtable hash=new Hashtable();
  TestTools.strict.commit();
  hash.computeIfAbsent(null,null);
}
@Test(expected = ReactiveAuditException.class)

相关文章