Tabnine Logo
Collections.emptySet
Code IndexAdd Tabnine to your IDE (free)

How to use
emptySet
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.emptySet (Showing top 20 results out of 47,745)

Refine searchRefine arrow

  • Set.add
  • Map.get
  • Collections.singleton
  • Set.isEmpty
  • Set.size
  • Map.put
  • Set.contains
  • List.size
  • Map.containsKey
origin: spring-projects/spring-framework

@Override
public Set<String> getMetaAnnotationTypes(String annotationName) {
  Set<String> metaAnnotationTypes = this.metaAnnotationMap.get(annotationName);
  return (metaAnnotationTypes != null ? metaAnnotationTypes : Collections.emptySet());
}
origin: square/retrofit

 private static Set<? extends Annotation> jsonAnnotations(Annotation[] annotations) {
  Set<Annotation> result = null;
  for (Annotation annotation : annotations) {
   if (annotation.annotationType().isAnnotationPresent(JsonQualifier.class)) {
    if (result == null) result = new LinkedHashSet<>();
    result.add(annotation);
   }
  }
  return result != null ? unmodifiableSet(result) : Collections.<Annotation>emptySet();
 }
}
origin: jenkinsci/jenkins

  @Override
  protected Iterable<? extends String> getEdges(String n) {
    // return variables referred from the variable.
    if (!refereeSetMap.containsKey(n)) {
      // there is a case a non-existing variable is referred...
      return Collections.emptySet();
    }
    return refereeSetMap.get(n);
  }
};
origin: apache/geode

Set getDependencySet(CompiledValue cv, boolean readOnly) {
 Set set = (Set) this.dependencyGraph.get(cv);
 if (set == null) {
  if (readOnly)
   return Collections.emptySet();
  set = new HashSet(1);
  this.dependencyGraph.put(cv, set);
 }
 return set;
}
origin: square/okhttp

/**
 * Returns the distinct query parameter names in this URL, like {@code ["a", "b"]} for {@code
 * http://host/?a=apple&b=banana}. If this URL has no query this returns the empty set.
 *
 * <p><table summary="">
 *   <tr><th>URL</th><th>{@code queryParameterNames()}</th></tr>
 *   <tr><td>{@code http://host/}</td><td>{@code []}</td></tr>
 *   <tr><td>{@code http://host/?}</td><td>{@code [""]}</td></tr>
 *   <tr><td>{@code http://host/?a=apple&k=key+lime}</td><td>{@code ["a", "k"]}</td></tr>
 *   <tr><td>{@code http://host/?a=apple&a=apricot}</td><td>{@code ["a"]}</td></tr>
 *   <tr><td>{@code http://host/?a=apple&b}</td><td>{@code ["a", "b"]}</td></tr>
 * </table>
 */
public Set<String> queryParameterNames() {
 if (queryNamesAndValues == null) return Collections.emptySet();
 Set<String> result = new LinkedHashSet<>();
 for (int i = 0, size = queryNamesAndValues.size(); i < size; i += 2) {
  result.add(queryNamesAndValues.get(i));
 }
 return Collections.unmodifiableSet(result);
}
origin: skylot/jadx

private Set<String> getAncestors(String clsName) {
  Set<String> result = ancestorCache.get(clsName);
  if (result != null) {
    return result;
  }
  NClass cls = nameMap.get(clsName);
  if (cls == null) {
    missingClasses.add(clsName);
    return Collections.emptySet();
  }
  result = new HashSet<>();
  addAncestorsNames(cls, result);
  if (result.isEmpty()) {
    result = Collections.emptySet();
  }
  ancestorCache.put(clsName, result);
  return result;
}
origin: spring-projects/spring-framework

public Collection<SourceClass> getAnnotationAttributes(String annType, String attribute) throws IOException {
  Map<String, Object> annotationAttributes = this.metadata.getAnnotationAttributes(annType, true);
  if (annotationAttributes == null || !annotationAttributes.containsKey(attribute)) {
    return Collections.emptySet();
  }
  String[] classNames = (String[]) annotationAttributes.get(attribute);
  Set<SourceClass> result = new LinkedHashSet<>();
  for (String className : classNames) {
    result.add(getRelated(className));
  }
  return result;
}
origin: pmd/pmd

private Set<String> styleForDepth(int depth, boolean inlineHighlight) {
  if (depth < 0) {
    // that's the style when we're outside any node
    return Collections.emptySet();
  } else {
    // Caching reduces the number of sets used by this step of the overlaying routine to
    // only a few. The number is probably blowing up during the actual spans overlaying
    // in StyleContext#recomputePainting
    DEPTH_STYLE_CACHE.putIfAbsent(style, new HashMap<>());
    Map<Integer, Map<Boolean, Set<String>>> depthToStyle = DEPTH_STYLE_CACHE.get(style);
    depthToStyle.putIfAbsent(depth, new HashMap<>());
    Map<Boolean, Set<String>> isInlineToStyle = depthToStyle.get(depth);
    if (isInlineToStyle.containsKey(inlineHighlight)) {
      return isInlineToStyle.get(inlineHighlight);
    }
    Set<String> s = new HashSet<>(style);
    s.add("depth-" + depth);
    if (inlineHighlight) {
      // inline highlight can be used to add boxing around a node if it wouldn't be ugly
      s.add("inline-highlight");
    }
    isInlineToStyle.put(inlineHighlight, s);
    return s;
  }
}
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: bumptech/glide

if (values.size() != 1) {
 throw new IllegalArgumentException("Expected single value, but found: " + values);
return Collections.emptySet();
Set<String> result = new HashSet<>(values.size());
for (Object current : values) {
 result.add(getExcludedModuleClassFromAnnotationAttribute(clazz, current));
return Collections.singleton(classType.toString());
origin: qunarcorp/qmq

public Set<ClientMetaInfo> aliveClientsOf(String subject) {
  final Map<ClientMetaInfo, Long> clients = allClients.get(subject);
  if (clients == null || clients.isEmpty()) {
    return Collections.emptySet();
  }
  final long now = System.currentTimeMillis();
  final Set<ClientMetaInfo> result = new HashSet<>();
  for (Map.Entry<ClientMetaInfo, Long> entry : clients.entrySet()) {
    if (entry.getValue() != null && now - entry.getValue() < EXPIRE_TIME_MS) {
      result.add(entry.getKey());
    }
  }
  return result;
}
origin: spring-projects/spring-security-oauth

public OAuth2Authentication extractAuthentication(Map<String, ?> map) {
  Map<String, String> parameters = new HashMap<String, String>();
  Set<String> scope = extractScope(map);
  Authentication user = userTokenConverter.extractAuthentication(map);
  String clientId = (String) map.get(clientIdAttribute);
  parameters.put(clientIdAttribute, clientId);
  if (includeGrantType && map.containsKey(GRANT_TYPE)) {
    parameters.put(GRANT_TYPE, (String) map.get(GRANT_TYPE));
  }
  Set<String> resourceIds = new LinkedHashSet<String>(map.containsKey(AUD) ? getAudience(map)
      : Collections.<String>emptySet());
  
  Collection<? extends GrantedAuthority> authorities = null;
  if (user==null && map.containsKey(AUTHORITIES)) {
    @SuppressWarnings("unchecked")
    String[] roles = ((Collection<String>)map.get(AUTHORITIES)).toArray(new String[0]);
    authorities = AuthorityUtils.createAuthorityList(roles);
  }
  OAuth2Request request = new OAuth2Request(parameters, clientId, authorities, true, scope, resourceIds, null, null,
      null);
  return new OAuth2Authentication(request, user);
}
origin: apache/kafka

PartitionInfo part1 = new PartitionInfo(topic, 1, node1, null, null);
Cluster cluster = new Cluster(null, Collections.singletonList(node1), Collections.singletonList(part1),
    Collections.emptySet(), Collections.emptySet());
accumulator.append(tp1, time.milliseconds(), "key".getBytes(),
    "value".getBytes(), Record.EMPTY_HEADERS, null, MAX_BLOCK_TIMEOUT);
Map<Integer, List<ProducerBatch>> drainedBatches = accumulator.drain(cluster, Collections.singleton(node1),
    Integer.MAX_VALUE,
    time.milliseconds());
assertTrue(drainedBatches.containsKey(node1.id()));
assertEquals(1, drainedBatches.get(node1.id()).size());
assertTrue(transactionManager.hasAbortableError());
origin: wildfly/wildfly

@Override
public Set<InetSocketAddress> allLocalAddresses() {
  try {
    final Set<SocketAddress> allLocalAddresses = sch.getAllLocalAddresses();
    final Set<InetSocketAddress> addresses = new LinkedHashSet<InetSocketAddress>(allLocalAddresses.size());
    for (SocketAddress socketAddress : allLocalAddresses) {
      addresses.add((InetSocketAddress) socketAddress);
    }
    return addresses;
  } catch (Throwable ignored) {
    return Collections.emptySet();
  }
}
origin: apache/kafka

@Test
public void testDeleteConsumerGroups() throws Exception {
  final HashMap<Integer, Node> nodes = new HashMap<>();
  nodes.put(0, new Node(0, "localhost", 8121));
  final Cluster cluster =
    new Cluster(
      "mockClusterId",
      nodes.values(),
      Collections.<PartitionInfo>emptyList(),
      Collections.<String>emptySet(),
      Collections.<String>emptySet(), nodes.get(0));
  final List<String> groupIds = singletonList("group-0");
  try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster)) {
    env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
    //Retriable FindCoordinatorResponse errors should be retried
    env.kafkaClient().prepareResponse(new FindCoordinatorResponse(Errors.COORDINATOR_NOT_AVAILABLE,  Node.noNode()));
    env.kafkaClient().prepareResponse(new FindCoordinatorResponse(Errors.COORDINATOR_LOAD_IN_PROGRESS, Node.noNode()));
    env.kafkaClient().prepareResponse(new FindCoordinatorResponse(Errors.NONE, env.cluster().controller()));
    final Map<String, Errors> response = new HashMap<>();
    response.put("group-0", Errors.NONE);
    env.kafkaClient().prepareResponse(new DeleteGroupsResponse(response));
    final DeleteConsumerGroupsResult result = env.adminClient().deleteConsumerGroups(groupIds);
    final KafkaFuture<Void> results = result.deletedGroups().get("group-0");
    assertNull(results.get());
    //should throw error for non-retriable errors
    env.kafkaClient().prepareResponse(new FindCoordinatorResponse(Errors.GROUP_AUTHORIZATION_FAILED,  Node.noNode()));
    final DeleteConsumerGroupsResult errorResult = env.adminClient().deleteConsumerGroups(groupIds);
    TestUtils.assertFutureError(errorResult.deletedGroups().get("group-0"), GroupAuthorizationException.class);
  }
}
origin: square/okhttp

/**
 * Returns the names of the request headers that need to be checked for equality when caching.
 */
public static Set<String> varyFields(Headers responseHeaders) {
 Set<String> result = Collections.emptySet();
 for (int i = 0, size = responseHeaders.size(); i < size; i++) {
  if (!"Vary".equalsIgnoreCase(responseHeaders.name(i))) continue;
  String value = responseHeaders.value(i);
  if (result.isEmpty()) {
   result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
  }
  for (String varyField : value.split(",")) {
   result.add(varyField.trim());
  }
 }
 return result;
}
origin: org.mockito/mockito-core

private void assureCanReadMockito(Set<Class<?>> types) {
  if (redefineModule == null) {
    return;
  }
  Set<Object> modules = new HashSet<Object>();
  try {
    Object target = getModule.invoke(Class.forName("org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher", false, null));
    for (Class<?> type : types) {
      Object module = getModule.invoke(type);
      if (!modules.contains(module) && !(Boolean) canRead.invoke(module, target)) {
        modules.add(module);
      }
    }
    for (Object module : modules) {
      redefineModule.invoke(instrumentation, module, Collections.singleton(target),
        Collections.emptyMap(), Collections.emptyMap(), Collections.emptySet(), Collections.emptyMap());
    }
  } catch (Exception e) {
    throw new IllegalStateException(join("Could not adjust module graph to make the mock instance dispatcher visible to some classes",
      "",
      "At least one of those modules: " + modules + " is not reading the unnamed module of the bootstrap loader",
      "Without such a read edge, the classes that are redefined to become mocks cannot access the mock dispatcher.",
      "To circumvent this, Mockito attempted to add a read edge to this module what failed for an unexpected reason"), e);
  }
}
origin: spring-projects/spring-framework

private Set<String> getPrefixesSet(String namespaceUri) {
  Assert.notNull(namespaceUri, "No namespaceUri given");
  if (this.defaultNamespaceUri.equals(namespaceUri)) {
    return Collections.singleton(XMLConstants.DEFAULT_NS_PREFIX);
  }
  else if (XMLConstants.XML_NS_URI.equals(namespaceUri)) {
    return Collections.singleton(XMLConstants.XML_NS_PREFIX);
  }
  else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri)) {
    return Collections.singleton(XMLConstants.XMLNS_ATTRIBUTE);
  }
  else {
    Set<String> prefixes = this.namespaceUriToPrefixes.get(namespaceUri);
    return (prefixes != null ?  Collections.unmodifiableSet(prefixes) : Collections.emptySet());
  }
}
origin: org.netbeans.api/org-openide-filesystems

  boolean canHaveRootAttributeOnReadOnlyFS(String name) {
    Set<String> tmp = rootAttributes;
    if (tmp == null) {
      tmp = new HashSet<String>();
      for (FileSystem fs : getDelegates()) {
        if (fs == null) {
          continue;
        }
        if (!fs.isReadOnly()) {
          continue;
        }
        Enumeration<String> en = fs.getRoot().getAttributes();
        while (en.hasMoreElements()) {
          tmp.add(en.nextElement());
        }
        rootAttributes = tmp;
      }
    }
    if (tmp == Collections.<String>emptySet()) {
      return true;
    }
    return tmp.contains(name);
  }
}
origin: google/guava

public void testForMapRemoveAll() {
 Map<String, Integer> map = Maps.newHashMap();
 map.put("foo", 1);
 map.put("bar", 2);
 map.put("cow", 3);
 Multimap<String, Integer> multimap = Multimaps.forMap(map);
 assertEquals(3, multimap.size());
 assertEquals(Collections.emptySet(), multimap.removeAll("dog"));
 assertEquals(3, multimap.size());
 assertTrue(multimap.containsKey("bar"));
 assertEquals(Collections.singleton(2), multimap.removeAll("bar"));
 assertEquals(2, multimap.size());
 assertFalse(multimap.containsKey("bar"));
}
java.utilCollectionsemptySet

Javadoc

Returns a type-safe empty, immutable Set.

Popular methods of Collections

  • emptyList
    Returns the empty list (immutable). This list is serializable.This example illustrates the type-safe
  • sort
  • singletonList
    Returns an immutable list containing only the specified object. The returned list is serializable.
  • unmodifiableList
    Returns an unmodifiable view of the specified list. This method allows modules to provide users with
  • emptyMap
    Returns the empty map (immutable). This map is serializable.This example illustrates the type-safe w
  • unmodifiableMap
    Returns an unmodifiable view of the specified map. This method allows modules to provide users with
  • singleton
    Returns an immutable set containing only the specified object. The returned set is serializable.
  • unmodifiableSet
    Returns an unmodifiable view of the specified set. This method allows modules to provide users with
  • singletonMap
    Returns an immutable map, mapping only the specified key to the specified value. The returned map is
  • addAll
    Adds all of the specified elements to the specified collection. Elements to be added may be specifie
  • reverse
    Reverses the order of the elements in the specified list. This method runs in linear time.
  • unmodifiableCollection
    Returns an unmodifiable view of the specified collection. This method allows modules to provide user
  • reverse,
  • unmodifiableCollection,
  • shuffle,
  • enumeration,
  • list,
  • synchronizedMap,
  • synchronizedList,
  • reverseOrder,
  • emptyIterator

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top Vim 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