Tabnine Logo
HashMap.isEmpty
Code IndexAdd Tabnine to your IDE (free)

How to use
isEmpty
method
in
java.util.HashMap

Best Java code snippets using java.util.HashMap.isEmpty (Showing top 20 results out of 8,955)

Refine searchRefine arrow

  • HashMap.put
  • HashMap.entrySet
  • Map.Entry.getValue
  • Map.Entry.getKey
  • Iterator.hasNext
  • Iterator.next
  • HashMap.get
  • Set.iterator
origin: apache/rocketmq

public String findBrokerAddressInPublish(final String brokerName) {
  HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
  if (map != null && !map.isEmpty()) {
    return map.get(MixAll.MASTER_ID);
  }
  return null;
}
origin: Netflix/eureka

public StringInterningAmazonInfoBuilder withMetadata(HashMap<String, String> metadata) {
  this.metadata = metadata;
  if (metadata.isEmpty()) {
    return this;
  }
  for (Map.Entry<String, String> entry : metadata.entrySet()) {
    String key = entry.getKey().intern();
    if (VALUE_INTERN_KEYS.containsKey(key)) {
      entry.setValue(StringCache.intern(entry.getValue()));
    }
  }
  return this;
}
origin: apache/hive

@Override
public MapJoinKey getAnyKey() {
 return mHash.isEmpty() ? null : mHash.keySet().iterator().next();
}
origin: apache/rocketmq

public FindBrokerResult findBrokerAddressInSubscribe(
  final String brokerName,
  final long brokerId,
  final boolean onlyThisBroker
) {
  String brokerAddr = null;
  boolean slave = false;
  boolean found = false;
  HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
  if (map != null && !map.isEmpty()) {
    brokerAddr = map.get(brokerId);
    slave = brokerId != MixAll.MASTER_ID;
    found = brokerAddr != null;
    if (!found && !onlyThisBroker) {
      Entry<Long, String> entry = map.entrySet().iterator().next();
      brokerAddr = entry.getValue();
      slave = entry.getKey() != MixAll.MASTER_ID;
      found = true;
    }
  }
  if (found) {
    return new FindBrokerResult(brokerAddr, slave, findBrokerVersion(brokerName, brokerAddr));
  }
  return null;
}
origin: lealone/Lealone

/**
 * Get the class id, or null if not found.
 *
 * @param clazz the class
 * @return the class id or null
 */
static Integer getCommonClassId(Class<?> clazz) {
  HashMap<Class<?>, Integer> map = COMMON_CLASSES_MAP;
  if (map.isEmpty()) {
    // lazy initialization
    for (int i = 0, size = COMMON_CLASSES.length; i < size; i++) {
      COMMON_CLASSES_MAP.put(COMMON_CLASSES[i], i);
    }
  }
  return map.get(clazz);
}
origin: apache/hbase

if (rsLogTimestampMap == null || rsLogTimestampMap.isEmpty()) {
 return null;
HashMap<String, HashMap<TableName, Long>> rsLogTimestampMapByRS = new HashMap<>();
for (Entry<TableName, HashMap<String, Long>> tableEntry : rsLogTimestampMap.entrySet()) {
 TableName table = tableEntry.getKey();
 HashMap<String, Long> rsLogTimestamp = tableEntry.getValue();
 for (Entry<String, Long> rsEntry : rsLogTimestamp.entrySet()) {
  String rs = rsEntry.getKey();
  Long ts = rsEntry.getValue();
  if (!rsLogTimestampMapByRS.containsKey(rs)) {
   rsLogTimestampMapByRS.put(rs, new HashMap<>());
   rsLogTimestampMapByRS.get(rs).put(table, ts);
  } else {
   rsLogTimestampMapByRS.get(rs).put(table, ts);
for (Entry<String, HashMap<TableName, Long>> entry : rsLogTimestampMapByRS.entrySet()) {
 String rs = entry.getKey();
 rsLogTimestampMins.put(rs, BackupUtils.getMinValue(entry.getValue()));
origin: prestodb/presto

public static AnnotationMap merge(AnnotationMap primary, AnnotationMap secondary)
{
  if (primary == null || primary._annotations == null || primary._annotations.isEmpty()) {
    return secondary;
  }
  if (secondary == null || secondary._annotations == null || secondary._annotations.isEmpty()) {
    return primary;
  }
  HashMap<Class<?>,Annotation> annotations = new HashMap<Class<?>,Annotation>();
  // add secondary ones first
  for (Annotation ann : secondary._annotations.values()) {
    annotations.put(ann.annotationType(), ann);
  }
  // to be overridden by primary ones
  for (Annotation ann : primary._annotations.values()) {
    annotations.put(ann.annotationType(), ann);
  }
  return new AnnotationMap(annotations);
}

origin: ankidroid/Anki-Android

/**
 * Get current model.
 * @param forDeck If true, it tries to get the deck specified in deck by mid, otherwise or if the former is not
 *                found, it uses the configuration`s field curModel.
 * @return The JSONObject of the model, or null if not found in the deck and in the configuration.
 */
public JSONObject current(boolean forDeck) {
  JSONObject m = null;
  if (forDeck) {
    m = get(mCol.getDecks().current().optLong("mid", -1));
  }
  if (m == null) {
    m = get(mCol.getConf().optLong("curModel", -1));
  }
  if (m == null) {
    if (!mModels.isEmpty()) {
      m = mModels.values().iterator().next();
    }
  }
  return m;
}
origin: igniterealtime/Smack

@Override
public HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) {
  HashMap<Integer, T_Sess> sessions = getCache(userDevice).sessions.get(contact);
  if (sessions == null) {
    sessions = new HashMap<>();
    getCache(userDevice).sessions.put(contact, sessions);
  }
  if (sessions.isEmpty() && persistent != null) {
    sessions.putAll(persistent.loadAllRawSessionsOf(userDevice, contact));
  }
  return new HashMap<>(sessions);
}
origin: hsz/idea-gitignore

  @Override
  public boolean visitFile(@NotNull VirtualFile file) {
    final HashMap<IgnoreEntry, Pattern> current = ContainerUtil.newHashMap(getCurrentValue());
    if (current.isEmpty()) {
      return false;
    }
    final String path = Utils.getRelativePath(root, file);
    if (path == null || Utils.isVcsDirectory(file)) {
      return false;
    }
    for (Map.Entry<IgnoreEntry, Pattern> item : current.entrySet()) {
      final Pattern value = item.getValue();
      boolean matches = false;
      if (value == null || matcher.match(value, path)) {
        matches = true;
        result.get(item.getKey()).add(file);
      }
      if (includeNested && matches) {
        current.put(item.getKey(), null);
      }
    }
    setValueForChildren(current);
    return true;
  }
};
origin: stanfordnlp/CoreNLP

    enhancedDependencies.put(parent.toCopyIndex(), relationString);
      enhancedDependencies.put(govIdx, reln.toString());
if (enhancedDependencies.isEmpty() && enhancedSg != null && enhancedSg.getRoots().contains(token)) {
  additionalDepsString = "0:root";
origin: apache/geode

/**
 * For each entry that is not dirty (all we did was read it) decrement its refcount (so it can be
 * evicted as we apply our writes) and remove it from entryMods (so we don't keep iterating over
 * it and se we don't try to clean it up again later).
 */
void cleanupNonDirtyEntries(InternalRegion r) {
 if (!this.entryMods.isEmpty()) {
  Iterator it = this.entryMods.entrySet().iterator();
  while (it.hasNext()) {
   Map.Entry me = (Map.Entry) it.next();
   // Object eKey = me.getKey();
   TXEntryState txes = (TXEntryState) me.getValue();
   if (txes.cleanupNonDirty(r)) {
    it.remove();
   }
  }
 }
}
origin: apache/drill

@Override
public MapJoinKey getAnyKey() {
 return mHash.isEmpty() ? null : mHash.keySet().iterator().next();
}
origin: Tencent/tinker

/**
 * Nullable
 *
 * @return HashMap<String, String>
 */
public HashMap<String, String> getPackagePropertiesIfPresent() {
  if (!packageProperties.isEmpty()) {
    return packageProperties;
  }
  String property = metaContentMap.get(ShareConstants.PACKAGE_META_FILE);
  if (property == null) {
    return null;
  }
  String[] lines = property.split("\n");
  for (final String line : lines) {
    if (line == null || line.length() <= 0) {
      continue;
    }
    //it is comment
    if (line.startsWith("#")) {
      continue;
    }
    final String[] kv = line.split("=", 2);
    if (kv == null || kv.length < 2) {
      continue;
    }
    packageProperties.put(kv[0].trim(), kv[1].trim());
  }
  return packageProperties;
}
origin: apache/geode

  if (serverToBucketsMap.get(server) == null) {
   HashSet<Integer> bucketSet = new HashSet<Integer>();
   bucketSet.add(bucketId);
   serverToBucketsMap.put(server, bucketSet);
  } else {
   HashSet<Integer> bucketSet = serverToBucketsMap.get(server);
   bucketSet.add(bucketId);
   serverToBucketsMap.put(server, bucketSet);
if (serverToBucketsMap.isEmpty()) {
 return null;
} else {
   (ServerLocation) serverToBucketsMap.keySet().toArray()[rand.nextInt(size)];
HashSet<Integer> bucketSet = serverToBucketsMap.get(randomFirstServer);
if (isDebugEnabled) {
 logger.debug(
prunedServerToBucketsMap.put(randomFirstServer, bucketSet);
serverToBucketsMap.remove(randomFirstServer);
 ServerLocation server = findNextServer(serverToBucketsMap.entrySet(), currentBucketSet);
 if (server == null) {
  break;
origin: redisson/redisson

public static AnnotationMap merge(AnnotationMap primary, AnnotationMap secondary)
{
  if (primary == null || primary._annotations == null || primary._annotations.isEmpty()) {
    return secondary;
  }
  if (secondary == null || secondary._annotations == null || secondary._annotations.isEmpty()) {
    return primary;
  }
  HashMap<Class<?>,Annotation> annotations = new HashMap<Class<?>,Annotation>();
  // add secondary ones first
  for (Annotation ann : secondary._annotations.values()) {
    annotations.put(ann.annotationType(), ann);
  }
  // to be overridden by primary ones
  for (Annotation ann : primary._annotations.values()) {
    annotations.put(ann.annotationType(), ann);
  }
  return new AnnotationMap(annotations);
}

origin: GlowstoneMC/Glowstone

private boolean getPickedUp(GlowPlayer player) {
  // todo: fire PlayerPickupItemEvent in a way that allows for 'remaining' calculations
  HashMap<Integer, ItemStack> map = player.getInventory().addItem(getItemStack());
  player
      .updateInventory(); // workaround for player editing slot & it immediately being
  // filled again
  if (!map.isEmpty()) {
    setItemStack(map.values().iterator().next());
    return false;
  } else {
    CollectItemMessage message = new CollectItemMessage(getEntityId(), player.getEntityId(),
        getItemStack().getAmount());
    world.playSound(location, Sound.ENTITY_ITEM_PICKUP, 0.3f, (float) (1 + Math.random()));
    world.getRawPlayers().stream().filter(other -> other.canSeeEntity(this))
        .forEach(other -> other.getSession().send(message));
    remove();
    return true;
  }
}
origin: lealone/Lealone

/**
 * Remove the right for the given role.
 *
 * @param role the role to revoke
 */
void revokeRole(Role role) {
  if (grantedRoles == null) {
    return;
  }
  Right right = grantedRoles.get(role);
  if (right == null) {
    return;
  }
  grantedRoles.remove(role);
  if (grantedRoles.isEmpty()) {
    grantedRoles = null;
  }
}
origin: geoserver/geoserver

public String[][] getHeaders(Object value, Operation operation) throws ServiceException {
  Response delegate = (Response) value;
  HashMap map = new HashMap();
  if (delegate.getContentDisposition() != null) {
    map.put("Content-Disposition", delegate.getContentDisposition());
  }
  HashMap m = delegate.getResponseHeaders();
  if (m != null && !m.isEmpty()) {
    map.putAll(m);
  }
  if (map == null || map.isEmpty()) return null;
  String[][] headers = new String[map.size()][2];
  List keys = new ArrayList(map.keySet());
  for (int i = 0; i < headers.length; i++) {
    headers[i][0] = (String) keys.get(i);
    headers[i][1] = (String) map.get(keys.get(i));
  }
  return headers;
}
origin: apache/hive

  for (Map.Entry<String, TableScanOperator> topOpEntry : topOps.entrySet()) {
   if (topOpEntry.getValue() == tso) {
    String newAlias = topOpEntry.getKey();
    if (!newAlias.equals(alias)) {
     joinAliases.set(index, newAlias);
      baseBigAlias = newAlias;
     aliasToNewAliasMap.put(alias, newAlias);
     alias = newAlias;
context.setBaseBigAlias(baseBigAlias);
context.setBigTablePartitioned(bigTablePartitioned);
if (!aliasToNewAliasMap.isEmpty()) {
 context.setAliasToNewAliasMap(aliasToNewAliasMap);
java.utilHashMapisEmpty

Javadoc

Returns whether this map is empty.

Popular methods of HashMap

  • <init>
    Constructs a new HashMap instance containing the mappings from the specified map.
  • put
    Maps the specified key to the specified value.
  • get
    Returns the value of the mapping with the specified key.
  • containsKey
    Returns whether this map contains the specified key.
  • keySet
    Returns a set of the keys contained in this map. The set is backed by this map so changes to one are
  • remove
  • entrySet
    Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry.
  • values
    Returns a collection of the values contained in this map. The collection is backed by this map so ch
  • size
    Returns the number of elements in this map.
  • clear
    Removes all mappings from this hash map, leaving it empty.
  • putAll
    Copies all the mappings in the specified map to this map. These mappings will replace all mappings t
  • clone
    Returns a shallow copy of this map.
  • putAll,
  • clone,
  • toString,
  • containsValue,
  • equals,
  • hashCode,
  • computeIfAbsent,
  • getOrDefault,
  • forEach

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • putExtra (Intent)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now