java.util.LinkedHashMap.containsKey()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(207)

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

LinkedHashMap.containsKey介绍

暂无

代码示例

代码示例来源:origin: alibaba/easyexcel

@Override
public void appendLister(String name, AnalysisEventListener listener) {
  if (!listeners.containsKey(name)) {
    listeners.put(name, listener);
  }
}

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

public synchronized <T extends Serializable> void updateTaskStatistics(MapRedStats mapRedStats,
  RunningJob rj, String taskId) throws IOException, JSONException {
 if (tasks.containsKey(taskId)) {
  tasks.get(taskId).updateMapRedStatsJson(mapRedStats, rj);
 }
}

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

public void addAggregationExprsForClause(String clause,
  LinkedHashMap<String, ASTNode> aggregationTrees) {
 if (destToAggregationExprs.containsKey(clause)) {
  destToAggregationExprs.get(clause).putAll(aggregationTrees);
 } else {
  destToAggregationExprs.put(clause, aggregationTrees);
 }
}

代码示例来源:origin: xuxueli/xxl-job

public String route(int jobId, List<String> addressList) {
  // cache clear
  if (System.currentTimeMillis() > CACHE_VALID_TIME) {
    jobLRUMap.clear();
    CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
  }
  // init lru
  LinkedHashMap<String, String> lruItem = jobLRUMap.get(jobId);
  if (lruItem == null) {
    /**
     * LinkedHashMap
     *      a、accessOrder:ture=访问顺序排序(get/put时排序);false=插入顺序排期;
     *      b、removeEldestEntry:新增元素时将会调用,返回true时会删除最老元素;可封装LinkedHashMap并重写该方法,比如定义最大容量,超出是返回true即可实现固定长度的LRU算法;
     */
    lruItem = new LinkedHashMap<String, String>(16, 0.75f, true);
    jobLRUMap.putIfAbsent(jobId, lruItem);
  }
  // put
  for (String address: addressList) {
    if (!lruItem.containsKey(address)) {
      lruItem.put(address, address);
    }
  }
  // load
  String eldestKey = lruItem.entrySet().iterator().next().getKey();
  String eldestValue = lruItem.get(eldestKey);
  return eldestValue;
}

代码示例来源:origin: google/guava

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: osmandapp/Osmand

/**
 * Add the key and return it's index code. If the key already is present, the previous
 * index code is returned and no insertion is done.
 *
 * @param key key to add
 * @return index of the key
 */
public int addKey(String key) {
  if (key == null) {
    throw new NullPointerException();
  }
  int nextIndex = keys.size();
  //final Integer mapIndex = keys.putIfAbsent(key, nextIndex);
  final Integer mapIndex;
  if (!keys.containsKey(key)) {
    mapIndex = keys.put(key, nextIndex);
  } else {
    mapIndex = keys.get(key);
  }
  return mapIndex == null ? nextIndex : mapIndex;
}

代码示例来源:origin: neo4j/neo4j

public Builder parameterizedWith( String name, TypeReference.Bound bound )
{
  if ( typeParameters == null )
  {
    typeParameters = new LinkedHashMap<>();
  }
  else if ( typeParameters.containsKey( name ) )
  {
    throw new IllegalArgumentException( name + " defined twice" );
  }
  typeParameters.put( name, bound );
  return this;
}

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

public void addAggregationExprsForClause(String clause,
  LinkedHashMap<String, ASTNode> aggregationTrees) {
 if (destToAggregationExprs.containsKey(clause)) {
  destToAggregationExprs.get(clause).putAll(aggregationTrees);
 } else {
  destToAggregationExprs.put(clause, aggregationTrees);
 }
}

代码示例来源:origin: Sable/soot

/**
 *
 * @param a
 *          Statement within the region
 *
 * @return The PDGNode that contains that unit, if this unit is in this region.
 */
public PDGNode unit2PDGNode(Unit u) {
 if (this.m_unit2pdgnode.containsKey(u)) {
  return this.m_unit2pdgnode.get(u);
 } else {
  return null;
 }
}

代码示例来源:origin: google/j2objc

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: gocd/gocd

private static void addToHistory(LinkedHashMap<String, Properties> propHistory, Map<String, Object> flatMap) {
  String id = String.valueOf(flatMap.get("pipelineid"));
  String key = (String) flatMap.get("key");
  String value = (String) flatMap.get("value");
  if (!propHistory.containsKey(id)) {
    propHistory.put(id, new Properties());
  }
  propHistory.get(id).add(new Property(key, value));
}

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

private void putIfMissing(LinkedHashMap<String, String> map, String key, String value) {
  if (map.containsKey(key) == false)
    map.put(key, value);
}

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

if (!targetPathToAliases.containsKey(pathToAdd)) {
 targetPathToAliases.put(pathToAdd, new ArrayList<String>());
targetPathToAliases.get(pathToAdd).add(sourceAlias);

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public Object optionValue(String name) {
  Option opt = new Option(name, null);
  if (declaredOptions.containsKey(opt)) {
    return declaredOptions.get(opt);
  }
  if (undeclaredOptions.containsKey(name)) {
    return undeclaredOptions.get(name);
  }
  return null;
}

代码示例来源:origin: wildfly/wildfly

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

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

public Collection<String> getUsedConversionClasses(Schema schema) {
 LinkedHashMap<String, Conversion<?>> classnameToConversion = new LinkedHashMap<>();
 for (Conversion<?> conversion : specificData.getConversions()) {
  classnameToConversion.put(conversion.getConvertedType().getCanonicalName(), conversion);
 }
 Collection<String> result = new HashSet<>();
 for (String className : getClassNamesOfPrimitiveFields(schema)) {
  if (classnameToConversion.containsKey(className)) {
   result.add(classnameToConversion.get(className).getClass().getCanonicalName());
  }
 }
 return result;
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

private void setType(final String type) {
  this.type = type;
  if (!TYPES.containsKey(type)) {
    TYPES.put(type, this);
  }
}

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

if (!targetPathToAliases.containsKey(pathToAdd)) {
 targetPathToAliases.put(pathToAdd, new ArrayList<String>());
targetPathToAliases.get(pathToAdd).add(sourceAlias);

代码示例来源:origin: zendesk/maxwell

public String buildPartitionKey(List<String> partitionColumns) {
  StringBuilder partitionKey= new StringBuilder();
  for (String pc : partitionColumns) {
    Object pcValue = null;
    if (data.containsKey(pc))
      pcValue = data.get(pc);
    if (pcValue != null)
      partitionKey.append(pcValue.toString());
  }
  return partitionKey.toString();
}

代码示例来源:origin: prestodb/presto

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

相关文章