static public void appendNames(StringBuilder builder, Collection<Object> names)
  {
    boolean first = true;
    for (Object name : names)
    {
      if (name instanceof Integer)
      {
        builder.append('[').append(name).append(']');
      }
      else
      {
        if (first == false)
        {
          builder.append('.');
        }
        builder.append(name);
      }
      first = false;
    }
  }
@Test
  public void testAppendNames()
  {
    Object inputs[][] =
    {
        {
          asCollection("a", 1, "b"),
          "a[1].b"
        },
        {
          asCollection(2, "b"),
          "[2].b"
        },
        {
          asCollection(3, 4, "b"),
          "[3][4].b"
        },
        {
          asCollection("a", "b", "c"),
          "a.b.c"
        },
        {
          asCollection("a", "b", 5, 6, "c", "d", 7, 8),
          "a.b[5][6].c.d[7][8]"
        },
    };
    for (Object[] input : inputs)
    {
      StringBuilder builder = new StringBuilder();
      @SuppressWarnings("unchecked")
      Collection<Object> names = (Collection<Object>) input[0];
      Data.appendNames(builder, names);
      String output = builder.toString();
      assertEquals(output, input[1]);
    }
  }