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

How to use
isEmpty
method
in
java.util.Set

Best Java code snippets using java.util.Set.isEmpty (Showing top 20 results out of 86,598)

Refine searchRefine arrow

  • Set.add
  • Set.iterator
  • Iterator.next
  • Set.size
  • Iterator.hasNext
  • Set.contains
origin: iluwatar/java-design-patterns

/**
 * Checkout object from pool
 */
public synchronized T checkOut() {
 if (available.isEmpty()) {
  available.add(create());
 }
 T instance = available.iterator().next();
 available.remove(instance);
 inUse.add(instance);
 return instance;
}
origin: apache/kafka

/**
 * returns the first partition (out of {@link #partitions}) for which no offset is defined.
 * @deprecated please use {@link #partitions}
 * @return a partition with no offset
 */
@Deprecated
public TopicPartition partition() {
  return partitions.isEmpty() ? null : partitions.iterator().next();
}
origin: prestodb/presto

private static Set<String> _merge(Set<String> s1, Set<String> s2)
{
  if (s1.isEmpty()) {
    return s2;
  } else if (s2.isEmpty()) {
    return s1;
  }
  HashSet<String> result = new HashSet<String>(s1.size() + s2.size());
  result.addAll(s1);
  result.addAll(s2);
  return result;
}
origin: spring-projects/spring-framework

private static Set<HttpMethod> initAllowedHttpMethods(Set<HttpMethod> declaredMethods) {
  if (declaredMethods.isEmpty()) {
    return EnumSet.allOf(HttpMethod.class).stream()
        .filter(method -> method != HttpMethod.TRACE)
        .collect(Collectors.toSet());
  }
  else {
    Set<HttpMethod> result = new LinkedHashSet<>(declaredMethods);
    if (result.contains(HttpMethod.GET)) {
      result.add(HttpMethod.HEAD);
    }
    result.add(HttpMethod.OPTIONS);
    return result;
  }
}
origin: spring-projects/spring-framework

private static Set<HttpMethod> initAllowedHttpMethods(Set<String> declaredMethods) {
  Set<HttpMethod> result = new LinkedHashSet<>(declaredMethods.size());
  if (declaredMethods.isEmpty()) {
    for (HttpMethod method : HttpMethod.values()) {
      if (method != HttpMethod.TRACE) {
        result.add(method);
      }
    }
  }
  else {
    for (String method : declaredMethods) {
      HttpMethod httpMethod = HttpMethod.valueOf(method);
      result.add(httpMethod);
      if (httpMethod == HttpMethod.GET) {
        result.add(HttpMethod.HEAD);
      }
    }
    result.add(HttpMethod.OPTIONS);
  }
  return result;
}
origin: alibaba/cobar

  /**
   * @param orig if null, return intersect
   */
  public static Set<? extends Object> intersectSet(Set<? extends Object> orig, Set<? extends Object> intersect) {
    if (orig == null)
      return intersect;
    if (intersect == null || orig.isEmpty())
      return Collections.emptySet();
    Set<Object> set = new HashSet<Object>(orig.size());
    for (Object p : orig) {
      if (intersect.contains(p))
        set.add(p);
    }
    return set;
  }
}
origin: spring-projects/spring-framework

@Override
public Enumeration<String> getParameterNames() {
  if (this.multipartParameterNames == null) {
    initializeMultipart();
  }
  if (this.multipartParameterNames.isEmpty()) {
    return super.getParameterNames();
  }
  // Servlet 3.0 getParameterNames() not guaranteed to include multipart form items
  // (e.g. on WebLogic 12) -> need to merge them here to be on the safe side
  Set<String> paramNames = new LinkedHashSet<>();
  Enumeration<String> paramEnum = super.getParameterNames();
  while (paramEnum.hasMoreElements()) {
    paramNames.add(paramEnum.nextElement());
  }
  paramNames.addAll(this.multipartParameterNames);
  return Collections.enumeration(paramNames);
}
origin: dropwizard/dropwizard

private Map<String, String> filterMdc(Map<String, String> mdcPropertyMap) {
  if (includesMdcKeys.isEmpty()) {
    return mdcPropertyMap;
  }
  return mdcPropertyMap.entrySet()
    .stream()
    .filter(e -> includesMdcKeys.contains(e.getKey()))
    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
origin: alibaba/druid

private void loadNameList() {
  Set<String> names = new HashSet<String>();
  for (String n : properties.stringPropertyNames()) {
    if (n.contains(".url")) {
      names.add(n.split("\\.url")[0]);
    }
  }
  if (!names.isEmpty()) {
    nameList.addAll(names);
  }
}
origin: MovingBlocks/Terasology

@Test
public void testOneDistanceIteration() {
  Iterator<Vector3i> iter = Diamond3iIterator.iterate(Vector3i.zero(), 1).iterator();
  Set<Vector3i> expected = Sets.newHashSet(Vector3i.zero(), new Vector3i(1, 0, 0), new Vector3i(-1, 0, 0), new Vector3i(0, 1, 0),
      new Vector3i(0, -1, 0), new Vector3i(0, 0, 1), new Vector3i(0, 0, -1));
  while (iter.hasNext()) {
    Vector3i next = iter.next();
    assertTrue("Received Unexpected: " + next, expected.remove(next));
  }
  assertTrue("Missing: " + expected, expected.isEmpty());
}
origin: eclipse-vertx/vert.x

@Test
public void testRegister() {
 assertTrue(vertx.verticleFactories().isEmpty());
 VerticleFactory fact1 = new TestVerticleFactory("foo");
 vertx.registerVerticleFactory(fact1);
 assertEquals(1, vertx.verticleFactories().size());
 assertTrue(vertx.verticleFactories().contains(fact1));
}
origin: spring-projects/spring-framework

@Override
public PersistenceUnitInfo obtainDefaultPersistenceUnitInfo() {
  if (this.persistenceUnitInfoNames.isEmpty()) {
    throw new IllegalStateException("No persistence units parsed from " +
        ObjectUtils.nullSafeToString(this.persistenceXmlLocations));
  }
  if (this.persistenceUnitInfos.isEmpty()) {
    throw new IllegalStateException("All persistence units from " +
        ObjectUtils.nullSafeToString(this.persistenceXmlLocations) + " already obtained");
  }
  if (this.persistenceUnitInfos.size() > 1 && this.defaultPersistenceUnitName != null) {
    return obtainPersistenceUnitInfo(this.defaultPersistenceUnitName);
  }
  PersistenceUnitInfo pui = this.persistenceUnitInfos.values().iterator().next();
  this.persistenceUnitInfos.clear();
  return pui;
}
origin: apache/storm

private int getParallelism(List<ProcessorNode> group) {
  Set<Integer> parallelisms = group.stream().map(Node::getParallelism).collect(Collectors.toSet());
  if (parallelisms.size() > 1) {
    throw new IllegalStateException("Current group does not have same parallelism " + group);
  }
  return parallelisms.isEmpty() ? 1 : parallelisms.iterator().next();
}
origin: org.assertj/assertj-core

/**
 * Checks that the {@code expectedNames} are part of the {@code actualNames}. If an {@code expectedName} is not
 * contained in the {@code actualNames}, the this method will return {@code true}. THe {@code missingNames} will
 * contain all the {@code expectedNames} that are not part of the {@code actualNames}.
 *
 * @param actualNames the names that should be used to check
 * @param expectedNames the names that should be contained in {@code actualNames}
 * @param missingNames the names that were not part of {@code expectedNames}
 * @return {@code true} if all {@code expectedNames} are part of the {@code actualNames}, {@code false} otherwise
 */
private static boolean noMissingElement(Set<String> actualNames, Set<String> expectedNames,
                    Set<String> missingNames) {
 for (String field : expectedNames) {
  if (!actualNames.contains(field)) missingNames.add(field);
 }
 return missingNames.isEmpty();
}
origin: robolectric/robolectric

@Implementation
protected @Nullable String[] getPackagesForUid(int uid) {
 String[] packageNames = packagesForUid.get(uid);
 if (packageNames != null) {
  return packageNames;
 }
 Set<String> results = new HashSet<>();
 for (PackageInfo packageInfo : packageInfos.values()) {
  if (packageInfo.applicationInfo != null && packageInfo.applicationInfo.uid == uid) {
   results.add(packageInfo.packageName);
  }
 }
 return results.isEmpty() ? null : results.toArray(new String[results.size()]);
}
origin: spring-projects/spring-framework

@Override
@Nullable
public String getPrefix(String namespaceUri) {
  Set<String> prefixes = getPrefixesSet(namespaceUri);
  return (!prefixes.isEmpty() ? prefixes.iterator().next() : null);
}
origin: apache/storm

@Test
public void testBlobSynchronizerForKeysToDownload() {
 BlobStore store = initLocalFs();
 LocalFsBlobStoreSynchronizer sync = new LocalFsBlobStoreSynchronizer(store, conf);
 // test for keylist to download
 Set<String> zkSet = new HashSet<String>();
 zkSet.add("key1");
 Set<String> blobStoreSet = new HashSet<String>();
 blobStoreSet.add("key1");
 Set<String> resultSet = sync.getKeySetToDownload(blobStoreSet, zkSet);
 assertTrue("Not Empty", resultSet.isEmpty());
 zkSet.add("key1");
 blobStoreSet.add("key2");
 resultSet =  sync.getKeySetToDownload(blobStoreSet, zkSet);
 assertTrue("Not Empty", resultSet.isEmpty());
 blobStoreSet.remove("key1");
 blobStoreSet.remove("key2");
 zkSet.add("key1");
 resultSet =  sync.getKeySetToDownload(blobStoreSet, zkSet);
 assertTrue("Unexpected keys to download", (resultSet.size() == 1) && (resultSet.contains("key1")));
}
origin: apache/incubator-dubbo

private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(
      metadata.getAnnotationAttributes(DubboComponentScan.class.getName()));
  String[] basePackages = attributes.getStringArray("basePackages");
  Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
  String[] value = attributes.getStringArray("value");
  // Appends value array attributes
  Set<String> packagesToScan = new LinkedHashSet<String>(Arrays.asList(value));
  packagesToScan.addAll(Arrays.asList(basePackages));
  for (Class<?> basePackageClass : basePackageClasses) {
    packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
  }
  if (packagesToScan.isEmpty()) {
    return Collections.singleton(ClassUtils.getPackageName(metadata.getClassName()));
  }
  return packagesToScan;
}
origin: dropwizard/dropwizard

private Map<String, String> filterHeaders(Map<String, String> headers, Set<String> filteredHeaderNames) {
  if (filteredHeaderNames.isEmpty()) {
    return Collections.emptyMap();
  }
  return headers.entrySet().stream()
    .filter(e -> filteredHeaderNames.contains(e.getKey()))
    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
origin: skylot/jadx

/**
 * Add exception type to catch block
 * @param type - null for 'all' or 'Throwable' handler
 */
public void addCatchType(@Nullable ClassInfo type) {
  if (type != null) {
    this.catchTypes.add(type);
  } else {
    if (!this.catchTypes.isEmpty()) {
      throw new JadxRuntimeException("Null type added to not empty exception handler: " + this);
    }
  }
}
java.utilSetisEmpty

Javadoc

Returns true if this set has no elements.

Popular methods of Set

  • add
    Adds the specified element to this set if it is not already present (optional operation). More forma
  • contains
    Returns true if this set contains the specified element. More formally, returns true if and only if
  • iterator
  • size
  • addAll
    Adds all of the elements in the specified collection to this set if they're not already present (opt
  • remove
    Removes the specified element from this set if it is present (optional operation). More formally, re
  • toArray
    Returns an array containing all of the elements in this set; the runtime type of the returned array
  • stream
  • clear
    Removes all of the elements from this set (optional operation). The set will be empty after this cal
  • removeAll
    Removes from this set all of its elements that are contained in the specified collection (optional o
  • forEach
  • equals
    Compares the specified object with this set for equality. Returnstrue if the specified object is als
  • forEach,
  • equals,
  • containsAll,
  • retainAll,
  • hashCode,
  • removeIf,
  • parallelStream,
  • spliterator,
  • of

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • putExtra (Intent)
  • getApplicationContext (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Best plugins for Eclipse
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