Java Collections.emptySet Examples

Java Collections.emptySet - 30 examples found. These are the top rated real world Java examples of java.util.Collections.emptySet extracted from open source projects. You can rate examples to help us improve the quality of examples.
  private Set<String> getSortedMethods(final Class<?> clazz, final Method[] methods) {
    final Set<String> sortedMethodNames = sortedMethods.get(clazz);
    if (sortedMethodNames == null) {
      final GroupOrder order = clazz.getAnnotation(GroupOrder.class);
      if (order == null) {
        sortedMethods.put(clazz, Collections.<String>emptySet());

        return Collections.emptySet();
      } else {
        final Set<String> result = new LinkedHashSet<>();
        for (final Class<?> groupClazz : order.value()) {
          for (final Method method : methods) {
            if (method.getReturnType() == groupClazz && method.getParameterTypes().length == 0) {
              result.add(method.getName());
            }
          }
        }
        sortedMethods.put(clazz, result);

        return result;
      }
    }

    return sortedMethodNames;
  }
  /** Test method for {@link net.sf.hajdbc.balancer.load.LoadBalancer#clear()}. */
  @Test
  public void clear() {
    Balancer<Void, MockDatabase> balancer =
        this.factory.createBalancer(Collections.<MockDatabase>emptySet());

    balancer.clear();
    assertEquals(Collections.<MockDatabase>emptySet(), balancer);

    balancer = this.factory.createBalancer(Collections.singleton(this.databases[0]));

    balancer.clear();
    assertEquals(Collections.<MockDatabase>emptySet(), balancer);

    balancer =
        this.factory.createBalancer(
            new HashSet<MockDatabase>(Arrays.asList(this.databases[0], this.databases[1])));

    balancer.clear();
    assertEquals(Collections.<MockDatabase>emptySet(), balancer);

    balancer =
        this.factory.createBalancer(new HashSet<MockDatabase>(Arrays.asList(this.databases)));

    balancer.clear();
    assertEquals(Collections.<MockDatabase>emptySet(), balancer);
  }
  @Test
  public void extractFieldNames() {
    assertEquals(Collections.emptySet(), plugin.extractFieldNames(""));
    assertEquals(Collections.emptySet(), plugin.extractFieldNames("text"));
    assertEquals(Collections.emptySet(), plugin.extractFieldNames("+(^:text"));
    assertEquals(Collections.emptySet(), plugin.extractFieldNames("foo :bar"));

    assertEquals(Collections.singleton("foo"), plugin.extractFieldNames("foo:bar"));
    assertEquals(Collections.singleton("both"), plugin.extractFieldNames("both:(one two)"));
    assertEquals(Collections.singleton("title__"), plugin.extractFieldNames("title__:text"));
    assertEquals(
        Collections.singleton("title_zh_TW"), plugin.extractFieldNames("title_zh_TW:text"));
    assertEquals(
        Collections.singleton("property.Blog.BlogPostClass.title"),
        plugin.extractFieldNames("property.Blog.BlogPostClass.title:value"));
    assertEquals(
        Collections.singleton("property.Blog.Blog..Post$5EClass.title"),
        plugin.extractFieldNames("property.Blog.Blog..Post$5EClass.title:value"));

    assertEquals(
        new HashSet<String>(
            Arrays.asList(
                "abc",
                "g_h.i",
                "m$n-o",
                "_\u0103\u00EE\u00E2\u0219\u021B\u00E8\u00E9\u00EA\u00EB")),
        plugin.extractFieldNames(
            "+abc:def AND -g_h.i:jkl AND (m$n-o:pqr OR "
                + "_\u0103\u00EE\u00E2\u0219\u021B\u00E8\u00E9\u00EA\u00EB:stu^3)"));
  }
 public void testConstrainedMapIllegal() {
   Map<String, Integer> map = Maps.newLinkedHashMap();
   Map<String, Integer> constrained = MapConstraints.constrainedMap(map, TEST_CONSTRAINT);
   try {
     constrained.put(TEST_KEY, TEST_VALUE);
     fail("TestKeyException expected");
   } catch (TestKeyException expected) {
   }
   try {
     constrained.put("baz", TEST_VALUE);
     fail("TestValueException expected");
   } catch (TestValueException expected) {
   }
   try {
     constrained.put(TEST_KEY, 3);
     fail("TestKeyException expected");
   } catch (TestKeyException expected) {
   }
   try {
     constrained.putAll(ImmutableMap.of("baz", 3, TEST_KEY, 4));
     fail("TestKeyException expected");
   } catch (TestKeyException expected) {
   }
   assertEquals(Collections.emptySet(), map.entrySet());
   assertEquals(Collections.emptySet(), constrained.entrySet());
 }
 @Override
 public void elementChanged(ElementChangedEvent event) {
   initializeCache(true);
   Set<IJavaProject> javaProjectsWithClasspathChange =
       javaProjectClasspathChangeAnalyzer.getJavaProjectsWithClasspathChange(event.getDelta());
   if (!javaProjectsWithClasspathChange.isEmpty()) {
     for (IJavaProject project : javaProjectsWithClasspathChange) {
       updateCache(project);
     }
   }
   for (IJavaElementDelta projectDelta : getProjectDeltas(event.getDelta())) {
     IJavaProject project = (IJavaProject) projectDelta.getElement();
     if ((projectDelta.getKind() & IJavaElementDelta.REMOVED) != 0) {
       clearCache(project, Collections.<PackageFragmentRootData>emptySet());
     }
     switch (projectDelta.getFlags()) {
       case IJavaElementDelta.F_OPENED:
         updateCache(project);
         break;
       case IJavaElementDelta.F_CLOSED:
         clearCache(project, Collections.<PackageFragmentRootData>emptySet());
         break;
     }
   }
 }
Example #6
0
  @Test
  public void testEmptyInputs() {
    TestTransaction tx1 = new TestTransaction(env);

    Set<Bytes> rowSet = Collections.singleton(Bytes.of("foo"));
    Set<Column> colSet = Collections.singleton(new Column("a", "b"));

    Set<Bytes> emptyRowSet = Collections.emptySet();
    Set<Column> emptyColSet = Collections.emptySet();
    Set<RowColumn> emptyRowColSet = Collections.emptySet();

    Assert.assertEquals(0, tx1.get(Bytes.of("foo"), emptyColSet).size());
    Assert.assertEquals(0, tx1.get(emptyRowSet, emptyColSet).size());
    Assert.assertEquals(0, tx1.get(emptyRowSet, colSet).size());
    Assert.assertEquals(0, tx1.get(rowSet, emptyColSet).size());
    Assert.assertEquals(0, tx1.get(rowSet, emptyColSet).size());
    Assert.assertEquals(0, tx1.get(emptyRowColSet).size());

    Set<String> erss = Collections.emptySet();
    Set<String> rss = Collections.singleton("foo");

    Assert.assertEquals(0, tx1.gets("foo", emptyColSet).size());
    Assert.assertEquals(0, tx1.gets(erss, emptyColSet).size());
    Assert.assertEquals(0, tx1.gets(erss, colSet).size());
    Assert.assertEquals(0, tx1.gets(rss, emptyColSet).size());
    Assert.assertEquals(0, tx1.gets(rss, emptyColSet).size());
    Assert.assertEquals(0, tx1.gets(emptyRowColSet).size());
  }