congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Collection.isEmpty
Code IndexAdd Tabnine to your IDE (free)

How to use
isEmpty
method
in
java.util.Collection

Best Java code snippets using java.util.Collection.isEmpty (Showing top 20 results out of 63,171)

Refine searchRefine arrow

  • Collection.iterator
  • Iterator.next
  • Collection.size
  • Iterator.hasNext
  • Collection.add
  • List.add
origin: google/guava

private static boolean isEmpty(Iterable<?> iterable) {
 return iterable instanceof Collection
   ? ((Collection<?>) iterable).isEmpty()
   : !iterable.iterator().hasNext();
}
origin: google/guava

/** Used during deserialization only. */
final void setMap(Map<K, Collection<V>> map) {
 this.map = map;
 totalSize = 0;
 for (Collection<V> values : map.values()) {
  checkArgument(!values.isEmpty());
  totalSize += values.size();
 }
}
origin: spring-projects/spring-framework

private String style(Collection<?> value) {
  StringBuilder result = new StringBuilder(value.size() * 8 + 16);
  result.append(getCollectionTypeString(value)).append('[');
  for (Iterator<?> i = value.iterator(); i.hasNext();) {
    result.append(style(i.next()));
    if (i.hasNext()) {
      result.append(',').append(' ');
    }
  }
  if (value.isEmpty()) {
    result.append(EMPTY);
  }
  result.append("]");
  return result.toString();
}
origin: redisson/redisson

@Override
public RFuture<Boolean> addAllAsync(Collection<? extends String> c) {
  if (c.isEmpty()) {
    return RedissonPromise.newSucceededFuture(false);
  }
  List<Object> params = new ArrayList<Object>(2*c.size());
  params.add(getName());
  for (Object param : c) {
    params.add(0);
    params.add(param);
  }
  return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZADD_BOOL_RAW, params.toArray());
}
origin: apache/incubator-shardingsphere

RoutingResult result = new RoutingResult();
if (shardingRule.isAllBroadcastTables(logicTables)) {
  List<RoutingTable> routingTables = new ArrayList<>(logicTables.size());
  for (String each : logicTables) {
    routingTables.add(new RoutingTable(each, each));
  result.getTableUnits().getTableUnits().add(tableUnit);
} else if (logicTables.isEmpty()) {
  result.getTableUnits().getTableUnits().add(new TableUnit(shardingRule.getShardingDataSourceNames().getRandomDataSourceName()));
} else if (1 == logicTables.size()) {
  String logicTableName = logicTables.iterator().next();
  DataNode dataNode = shardingRule.getDataNode(logicTableName);
  TableUnit tableUnit = new TableUnit(dataNode.getDataSourceName());
  tableUnit.getRoutingTables().add(new RoutingTable(logicTableName, dataNode.getTableName()));
  result.getTableUnits().getTableUnits().add(tableUnit);
} else {
  List<RoutingTable> routingTables = new ArrayList<>(logicTables.size());
  Set<String> availableDatasourceNames = null;
  boolean first = true;
    TableRule tableRule = shardingRule.getTableRule(each);
    DataNode dataNode = tableRule.getActualDataNodes().get(0);
    routingTables.add(new RoutingTable(each, dataNode.getTableName()));
    Set<String> currentDataSourceNames = new HashSet<>(tableRule.getActualDatasourceNames().size());
    for (DataNode eachDataNode : tableRule.getActualDataNodes()) {
origin: stanfordnlp/CoreNLP

/** Returns the (first) root of this SemanticGraph. */
public IndexedWord getFirstRoot() {
 if (roots.isEmpty())
  throw new RuntimeException("No roots in graph:\n" + this
    + "\nFind where this graph was created and make sure you're adding roots.");
 return roots.iterator().next();
}
origin: commons-collections/commons-collections

public boolean removeAll(Collection coll) {
  if (parent.isEmpty() || coll.isEmpty()) {
    return false;
  }
  boolean modified = false;
  Iterator it = iterator();
  while (it.hasNext()) {
    if (coll.contains(it.next())) {
      it.remove();
      modified = true;
    }
  }
  return modified;
}
origin: apache/incubator-shardingsphere

@Override
public RoutingResult route() {
  Collection<RoutingResult> result = new ArrayList<>(logicTables.size());
  Collection<String> bindingTableNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
  for (String each : logicTables) {
    if (tableRule.isPresent()) {
      if (!bindingTableNames.contains(each)) {
        result.add(new StandardRoutingEngine(shardingRule, tableRule.get().getLogicTable(), shardingConditions).route());
  if (result.isEmpty()) {
    throw new ShardingException("Cannot find table rule and default data source with logic tables: '%s'", logicTables);
  if (1 == result.size()) {
    return result.iterator().next();
origin: apache/shiro

public Collection<V> values() {
  processQueue();
  Collection<K> keys = map.keySet();
  if (keys.isEmpty()) {
    //noinspection unchecked
    return Collections.EMPTY_SET;
  }
  Collection<V> values = new ArrayList<V>(keys.size());
  for (K key : keys) {
    V v = get(key);
    if (v != null) {
      values.add(v);
    }
  }
  return values;
}
origin: stagemonitor/stagemonitor

private static void initIncludesAndExcludes() {
  CorePlugin corePlugin = Stagemonitor.getPlugin(CorePlugin.class);
  excludeContaining = new ArrayList<String>(corePlugin.getExcludeContaining().size());
  excludeContaining.addAll(corePlugin.getExcludeContaining());
  excludes = new ArrayList<String>(corePlugin.getExcludePackages().size());
  excludes.add("org.stagemonitor");
  excludes.addAll(corePlugin.getExcludePackages());
  includes = new ArrayList<String>(corePlugin.getIncludePackages().size());
  includes.addAll(corePlugin.getIncludePackages());
  if (includes.isEmpty()) {
    logger.warn("No includes for instrumentation configured. Please set the stagemonitor.instrument.include property.");
  }
}
origin: spring-projects/spring-framework

@Nullable
private Collection<CacheOperation> parseCacheAnnotations(
    DefaultCacheConfig cachingConfig, AnnotatedElement ae, boolean localOnly) {
  Collection<? extends Annotation> anns = (localOnly ?
      AnnotatedElementUtils.getAllMergedAnnotations(ae, CACHE_OPERATION_ANNOTATIONS) :
      AnnotatedElementUtils.findAllMergedAnnotations(ae, CACHE_OPERATION_ANNOTATIONS));
  if (anns.isEmpty()) {
    return null;
  }
  final Collection<CacheOperation> ops = new ArrayList<>(1);
  anns.stream().filter(ann -> ann instanceof Cacheable).forEach(
      ann -> ops.add(parseCacheableAnnotation(ae, cachingConfig, (Cacheable) ann)));
  anns.stream().filter(ann -> ann instanceof CacheEvict).forEach(
      ann -> ops.add(parseEvictAnnotation(ae, cachingConfig, (CacheEvict) ann)));
  anns.stream().filter(ann -> ann instanceof CachePut).forEach(
      ann -> ops.add(parsePutAnnotation(ae, cachingConfig, (CachePut) ann)));
  anns.stream().filter(ann -> ann instanceof Caching).forEach(
      ann -> parseCachingAnnotation(ae, cachingConfig, (Caching) ann, ops));
  return ops;
}
origin: apache/ignite

/**
 * Gets size of the given collection with provided optional predicates.
 *
 * @param c Collection to size.
 * @param p Optional predicates that filters out elements from count.
 * @param <T> Type of the iterator.
 * @return Number of elements in the collection for which all given predicates
 *      evaluates to {@code true}. If no predicates is provided - all elements are counted.
 */
public static <T> int size(@Nullable Collection<? extends T> c, @Nullable IgnitePredicate<? super T>... p) {
  return c == null || c.isEmpty() ? 0 : isEmpty(p) || isAlwaysTrue(p) ? c.size() : size(c.iterator(), p);
}
origin: google/guava

@CanIgnoreReturnValue
@Override
public boolean putAll(@Nullable K key, Iterable<? extends V> values) {
 checkNotNull(values);
 // make sure we only call values.iterator() once
 // and we only call get(key) if values is nonempty
 if (values instanceof Collection) {
  Collection<? extends V> valueCollection = (Collection<? extends V>) values;
  return !valueCollection.isEmpty() && get(key).addAll(valueCollection);
 } else {
  Iterator<? extends V> valueItr = values.iterator();
  return valueItr.hasNext() && Iterators.addAll(get(key), valueItr);
 }
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public GridClientData pinNodes(GridClientNode node, GridClientNode... nodes) throws GridClientException {
  Collection<GridClientNode> pinnedNodes = new ArrayList<>(nodes != null ? nodes.length + 1 : 1);
  if (node != null)
    pinnedNodes.add(node);
  if (nodes != null && nodes.length != 0)
    pinnedNodes.addAll(Arrays.asList(nodes));
  return createProjection(pinnedNodes.isEmpty() ? null : pinnedNodes,
    null, null, new GridClientDataFactory(flags));
}
origin: google/guava

/** An implementation of {@link Multiset#addAll}. */
static <E> boolean addAllImpl(Multiset<E> self, Collection<? extends E> elements) {
 checkNotNull(self);
 checkNotNull(elements);
 if (elements instanceof Multiset) {
  return addAllImpl(self, cast(elements));
 } else if (elements.isEmpty()) {
  return false;
 } else {
  return Iterators.addAll(self, elements.iterator());
 }
}
origin: google/guava

boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) {
 Iterator<Entry<K, Collection<V>>> entryIterator = unfiltered.asMap().entrySet().iterator();
 boolean changed = false;
 while (entryIterator.hasNext()) {
  Entry<K, Collection<V>> entry = entryIterator.next();
  K key = entry.getKey();
  Collection<V> collection = filterCollection(entry.getValue(), new ValuePredicate(key));
  if (!collection.isEmpty() && predicate.apply(Maps.immutableEntry(key, collection))) {
   if (collection.size() == entry.getValue().size()) {
    entryIterator.remove();
   } else {
    collection.clear();
   }
   changed = true;
  }
 }
 return changed;
}
origin: redisson/redisson

@Override
public RFuture<Boolean> addAllAsync(Collection<? extends String> c) {
  if (c.isEmpty()) {
    return RedissonPromise.newSucceededFuture(false);
  }
  List<Object> params = new ArrayList<Object>(2*c.size());
  params.add(getName());
  for (Object param : c) {
    params.add(0);
    params.add(param);
  }
  return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZADD_BOOL_RAW, params.toArray());
}
origin: apache/incubator-shardingsphere

@Override
public final int getTransactionIsolation() throws SQLException {
  if (cachedConnections.values().isEmpty()) {
    return transactionIsolation;
  }
  return cachedConnections.values().iterator().next().getTransactionIsolation();
}

origin: google/guava

} else if (elements instanceof Collection) {
 Collection<E> collection = (Collection<E>) elements;
 if (collection.isEmpty()) {
  return ImmutableSet.of();
 } else {
 if (itr.hasNext()) {
  EnumSet<E> enumSet = EnumSet.of(itr.next());
  Iterators.addAll(enumSet, itr);
  return ImmutableEnumSet.asImmutable(enumSet);
origin: apache/incubator-shardingsphere

/**
 * Load proxy configuration.
 *
 * @return proxy configuration
 * @throws IOException IO exception
 */
public ShardingConfiguration load() throws IOException {
  Collection<String> schemaNames = new HashSet<>();
  YamlProxyServerConfiguration serverConfig = loadServerConfiguration(new File(ShardingConfigurationLoader.class.getResource(CONFIG_PATH + SERVER_CONFIG_FILE).getFile()));
  File configPath = new File(ShardingConfigurationLoader.class.getResource(CONFIG_PATH).getFile());
  Collection<YamlProxyRuleConfiguration> ruleConfigurations = new LinkedList<>();
  for (File each : findRuleConfigurationFiles(configPath)) {
    Optional<YamlProxyRuleConfiguration> ruleConfig = loadRuleConfiguration(each, serverConfig);
    if (ruleConfig.isPresent()) {
      Preconditions.checkState(schemaNames.add(ruleConfig.get().getSchemaName()), "Schema name `%s` must unique at all rule configurations.", ruleConfig.get().getSchemaName());
      ruleConfigurations.add(ruleConfig.get());
    }
  }
  Preconditions.checkState(!ruleConfigurations.isEmpty() || null != serverConfig.getOrchestration(), "Can not find any sharding rule configuration file in path `%s`.", configPath.getPath());
  Map<String, YamlProxyRuleConfiguration> ruleConfigurationMap = new HashMap<>(ruleConfigurations.size(), 1);
  for (YamlProxyRuleConfiguration each : ruleConfigurations) {
    ruleConfigurationMap.put(each.getSchemaName(), each);
  }
  return new ShardingConfiguration(serverConfig, ruleConfigurationMap);
}

java.utilCollectionisEmpty

Javadoc

Returns if this Collection contains no elements.

Popular methods of Collection

  • size
    Returns the number of elements in this collection. If this collection contains more than Integer.MAX
  • iterator
    Returns an iterator over the elements in this collection. There are no guarantees concerning the ord
  • add
  • contains
  • toArray
  • stream
  • addAll
  • forEach
  • remove
  • clear
  • removeAll
  • containsAll
  • removeAll,
  • containsAll,
  • equals,
  • hashCode,
  • retainAll,
  • removeIf,
  • parallelStream,
  • spliterator,
  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • setContentView (Activity)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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