static boolean objectIsAcyclic(Object object)
  {
    if (object == null)
    {
      return true;
    }

    Class<?> klass = object.getClass();
    if (isPrimitiveClass(klass))
    {
      return true;
    }
    else if (isComplexClass(klass))
    {
      DataComplex complex = (DataComplex) object;
      try
      {
        Data.traverse(complex, new TraverseCallback() {});
        return true;
      }
      catch (IOException e)
      {
        return false;
      }
    }
    else
    {
      throw new IllegalStateException("Object of unknown type: " + object);
    }
  }
@Test
  public void testObjectIsAcyclic()
  {
    assertTrue(Data.objectIsAcyclic(true));
    assertTrue(Data.objectIsAcyclic(1));
    assertTrue(Data.objectIsAcyclic(1L));
    assertTrue(Data.objectIsAcyclic(1.0f));
    assertTrue(Data.objectIsAcyclic(1.0));
    assertTrue(Data.objectIsAcyclic("string"));
    assertTrue(Data.objectIsAcyclic(new DataMap()));
    assertTrue(Data.objectIsAcyclic(new DataList()));

    DataMap a = new DataMap();
    DataList b = new DataList();
    DataMap c = new DataMap();

    a.put("b", b);
    a.put("c", c);

    assertTrue(Data.objectIsAcyclic(a));
    assertTrue(Data.objectIsAcyclic(b));
    assertTrue(Data.objectIsAcyclic(c));

    DataMap dm = new DataMap();
    b.add(dm);
    c.put("d", dm);

    assertTrue(Data.objectIsAcyclic(a));
    assertTrue(Data.objectIsAcyclic(b));
    assertTrue(Data.objectIsAcyclic(c));
    assertTrue(Data.objectIsAcyclic(dm));

    DataList e = new DataList();
    DataMap f = new DataMap();

    dm.put("e", e);
    dm.put("f", f);

    assertTrue(Data.objectIsAcyclic(a));
    assertTrue(Data.objectIsAcyclic(b));
    assertTrue(Data.objectIsAcyclic(c));
    assertTrue(Data.objectIsAcyclic(dm));
    assertTrue(Data.objectIsAcyclic(e));
    assertTrue(Data.objectIsAcyclic(f));

    a.disableChecker();
    b.disableChecker();
    c.disableChecker();
    dm.disableChecker();
    e.disableChecker();
    f.disableChecker();

    // loop from e to e
    assertTrue(Data.objectIsAcyclic(a));
    e.add(e);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertFalse(Data.objectIsAcyclic(e));
    assertTrue(Data.objectIsAcyclic(f));
    e.remove(0);

    // loop from e to dm
    assertTrue(Data.objectIsAcyclic(a));
    e.add(dm);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertFalse(Data.objectIsAcyclic(e));
    assertTrue(Data.objectIsAcyclic(f));
    e.remove(0);

    // loop from e to c
    assertTrue(Data.objectIsAcyclic(a));
    e.add(c);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertFalse(Data.objectIsAcyclic(e));
    assertTrue(Data.objectIsAcyclic(f));
    e.remove(0);

    // loop from e to b
    assertTrue(Data.objectIsAcyclic(a));
    e.add(b);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertFalse(Data.objectIsAcyclic(e));
    assertTrue(Data.objectIsAcyclic(f));
    e.remove(0);

    // loop from e to a
    assertTrue(Data.objectIsAcyclic(a));
    e.add(a);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertFalse(Data.objectIsAcyclic(e));
    assertTrue(Data.objectIsAcyclic(f));
    e.remove(0);

    // loop from f to f
    assertTrue(Data.objectIsAcyclic(a));
    f.put("f", f);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertTrue(Data.objectIsAcyclic(e));
    assertFalse(Data.objectIsAcyclic(f));
    f.remove("f");

    // loop from f to dm
    assertTrue(Data.objectIsAcyclic(a));
    f.put("d", dm);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertTrue(Data.objectIsAcyclic(e));
    assertFalse(Data.objectIsAcyclic(f));
    f.remove("d");

    // loop from f to c
    assertTrue(Data.objectIsAcyclic(a));
    f.put("c", c);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertTrue(Data.objectIsAcyclic(e));
    assertFalse(Data.objectIsAcyclic(f));
    f.remove("c");

    // loop from f to b
    assertTrue(Data.objectIsAcyclic(a));
    f.put("b", b);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertTrue(Data.objectIsAcyclic(e));
    assertFalse(Data.objectIsAcyclic(f));
    f.remove("b");

    // loop from f to a
    assertTrue(Data.objectIsAcyclic(a));
    f.put("a", a);
    assertFalse(Data.objectIsAcyclic(a));
    assertFalse(Data.objectIsAcyclic(b));
    assertFalse(Data.objectIsAcyclic(c));
    assertFalse(Data.objectIsAcyclic(dm));
    assertTrue(Data.objectIsAcyclic(e));
    assertFalse(Data.objectIsAcyclic(f));
    f.remove("a");
  }