@Test public void test_Circular_Reference() throws Exception { PojoUtilsTest.Parent parent = new PojoUtilsTest.Parent(); parent.setAge(Integer.MAX_VALUE); parent.setEmail("a@b"); parent.setName("zhangsan"); PojoUtilsTest.Child child = new PojoUtilsTest.Child(); child.setAge(100); child.setName("lisi"); child.setParent(parent); parent.setChild(child); JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(parent, JavaBeanAccessor.METHOD); Assert.assertTrue(descriptor.isBeanType()); assertEqualsPrimitive(parent.getAge(), descriptor.getProperty("age")); assertEqualsPrimitive(parent.getName(), descriptor.getProperty("name")); assertEqualsPrimitive(parent.getEmail(), descriptor.getProperty("email")); JavaBeanDescriptor childDescriptor = (JavaBeanDescriptor) descriptor.getProperty("child"); Assert.assertTrue(descriptor == childDescriptor.getProperty("parent")); assertEqualsPrimitive(child.getName(), childDescriptor.getProperty("name")); assertEqualsPrimitive(child.getAge(), childDescriptor.getProperty("age")); }
public static JavaBeanDescriptor serialize(Object obj) { return serialize(obj, JavaBeanAccessor.FIELD); }
JavaBeanSerializeUtil { public static JavaBeanDescriptor serialize(Object obj) { return serialize(obj, JavaBeanAccessor.FIELD); } }
JavaBeanSerializeUtil { public static JavaBeanDescriptor serialize(Object obj) { return serialize(obj, JavaBeanAccessor.FIELD); } private  JavaBeanSerializeUtil(); }
JavaBeanSerializeUtil { public static JavaBeanDescriptor serialize(Object obj) { return serialize(obj, JavaBeanAccessor.FIELD); } private  JavaBeanSerializeUtil(); static JavaBeanDescriptor serialize(Object obj); static JavaBeanDescriptor serialize(Object obj, JavaBeanAccessor accessor); static Object deserialize(JavaBeanDescriptor beanDescriptor); static Object deserialize(JavaBeanDescriptor beanDescriptor, ClassLoader loader); static Class<?> name2Class(ClassLoader loader, String name); }
JavaBeanSerializeUtil { public static JavaBeanDescriptor serialize(Object obj) { return serialize(obj, JavaBeanAccessor.FIELD); } private  JavaBeanSerializeUtil(); static JavaBeanDescriptor serialize(Object obj); static JavaBeanDescriptor serialize(Object obj, JavaBeanAccessor accessor); static Object deserialize(JavaBeanDescriptor beanDescriptor); static Object deserialize(JavaBeanDescriptor beanDescriptor, ClassLoader loader); static Class<?> name2Class(ClassLoader loader, String name);  }