Java源码示例:com.alibaba.dubbo.common.model.person.Phone
示例1
static void assertEqualsPhone(Phone excpected, Object obj) {
JavaBeanDescriptor descriptor = (JavaBeanDescriptor) obj;
Assert.assertTrue(descriptor.isBeanType());
if (excpected.getArea() != null) {
assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area"));
}
if (excpected.getCountry() != null) {
assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country"));
}
if (excpected.getExtensionNumber() != null) {
assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber"));
}
if (excpected.getNumber() != null) {
assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number"));
}
}
示例2
static void assertEqualsPhone(Phone excpected, Object obj) {
JavaBeanDescriptor descriptor = (JavaBeanDescriptor)obj;
Assert.assertTrue(descriptor.isBeanType());
if (excpected.getArea() != null) {
assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area"));
}
if (excpected.getCountry() != null) {
assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country"));
}
if (excpected.getExtensionNumber()!= null) {
assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber"));
}
if (excpected.getNumber() != null) {
assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number"));
}
}
示例3
static void assertEqualsPhone(Phone excpected, Object obj) {
JavaBeanDescriptor descriptor = (JavaBeanDescriptor)obj;
Assert.assertTrue(descriptor.isBeanType());
if (excpected.getArea() != null) {
assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area"));
}
if (excpected.getCountry() != null) {
assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country"));
}
if (excpected.getExtensionNumber()!= null) {
assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber"));
}
if (excpected.getNumber() != null) {
assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number"));
}
}
示例4
static void assertEqualsPhone(Phone excpected, Object obj) {
JavaBeanDescriptor descriptor = (JavaBeanDescriptor)obj;
Assert.assertTrue(descriptor.isBeanType());
if (excpected.getArea() != null) {
assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area"));
}
if (excpected.getCountry() != null) {
assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country"));
}
if (excpected.getExtensionNumber()!= null) {
assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber"));
}
if (excpected.getNumber() != null) {
assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number"));
}
}
示例5
static void assertEqualsPhone(Phone excpected, Object obj) {
JavaBeanDescriptor descriptor = (JavaBeanDescriptor)obj;
Assert.assertTrue(descriptor.isBeanType());
if (excpected.getArea() != null) {
assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area"));
}
if (excpected.getCountry() != null) {
assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country"));
}
if (excpected.getExtensionNumber()!= null) {
assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber"));
}
if (excpected.getNumber() != null) {
assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number"));
}
}
示例6
static void assertEqualsPhone(Phone excpected, Object obj) {
JavaBeanDescriptor descriptor = (JavaBeanDescriptor)obj;
Assert.assertTrue(descriptor.isBeanType());
if (excpected.getArea() != null) {
assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area"));
}
if (excpected.getCountry() != null) {
assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country"));
}
if (excpected.getExtensionNumber()!= null) {
assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber"));
}
if (excpected.getNumber() != null) {
assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number"));
}
}
示例7
@Test
public void testDeserializeBean() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor beanDescriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Object deser = JavaBeanSerializeUtil.deserialize(beanDescriptor);
Assert.assertTrue(deser instanceof Bean);
Bean deserBean = (Bean) deser;
Assert.assertEquals(bean.getDate(), deserBean.getDate());
Assert.assertEquals(bean.getStatus(), deserBean.getStatus());
Assert.assertEquals(bean.getType(), deserBean.getType());
Assert.assertEquals(bean.getCollection().size(), deserBean.getCollection().size());
Assert.assertEquals(bean.getCollection().iterator().next().getClass(),
deserBean.getCollection().iterator().next().getClass());
Assert.assertEquals(bean.getAddresses().size(), deserBean.getAddresses().size());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getKey(),
deserBean.getAddresses().entrySet().iterator().next().getKey());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getValue().getClass(),
deserBean.getAddresses().entrySet().iterator().next().getValue().getClass());
}
示例8
@Test
public void testDeserializeBean() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor beanDescriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Object deser = JavaBeanSerializeUtil.deserialize(beanDescriptor);
Assert.assertTrue(deser instanceof Bean);
Bean deserBean = (Bean)deser;
Assert.assertEquals(bean.getDate(), deserBean.getDate());
Assert.assertEquals(bean.getStatus(), deserBean.getStatus());
Assert.assertEquals(bean.getType(), deserBean.getType());
Assert.assertEquals(bean.getCollection().size(), deserBean.getCollection().size());
Assert.assertEquals(bean.getCollection().iterator().next().getClass(),
deserBean.getCollection().iterator().next().getClass());
Assert.assertEquals(bean.getAddresses().size(), deserBean.getAddresses().size());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getKey(),
deserBean.getAddresses().entrySet().iterator().next().getKey());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getValue().getClass(),
deserBean.getAddresses().entrySet().iterator().next().getValue().getClass());
}
示例9
@Test
public void testDeserializeBean() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor beanDescriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Object deser = JavaBeanSerializeUtil.deserialize(beanDescriptor);
Assert.assertTrue(deser instanceof Bean);
Bean deserBean = (Bean)deser;
Assert.assertEquals(bean.getDate(), deserBean.getDate());
Assert.assertEquals(bean.getStatus(), deserBean.getStatus());
Assert.assertEquals(bean.getType(), deserBean.getType());
Assert.assertEquals(bean.getCollection().size(), deserBean.getCollection().size());
Assert.assertEquals(bean.getCollection().iterator().next().getClass(),
deserBean.getCollection().iterator().next().getClass());
Assert.assertEquals(bean.getAddresses().size(), deserBean.getAddresses().size());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getKey(),
deserBean.getAddresses().entrySet().iterator().next().getKey());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getValue().getClass(),
deserBean.getAddresses().entrySet().iterator().next().getValue().getClass());
}
示例10
@Test
public void testDeserializeBean() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor beanDescriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Object deser = JavaBeanSerializeUtil.deserialize(beanDescriptor);
Assert.assertTrue(deser instanceof Bean);
Bean deserBean = (Bean)deser;
Assert.assertEquals(bean.getDate(), deserBean.getDate());
Assert.assertEquals(bean.getStatus(), deserBean.getStatus());
Assert.assertEquals(bean.getType(), deserBean.getType());
Assert.assertEquals(bean.getCollection().size(), deserBean.getCollection().size());
Assert.assertEquals(bean.getCollection().iterator().next().getClass(),
deserBean.getCollection().iterator().next().getClass());
Assert.assertEquals(bean.getAddresses().size(), deserBean.getAddresses().size());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getKey(),
deserBean.getAddresses().entrySet().iterator().next().getKey());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getValue().getClass(),
deserBean.getAddresses().entrySet().iterator().next().getValue().getClass());
}
示例11
@Test
public void testDeserializeBean() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor beanDescriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Object deser = JavaBeanSerializeUtil.deserialize(beanDescriptor);
Assert.assertTrue(deser instanceof Bean);
Bean deserBean = (Bean)deser;
Assert.assertEquals(bean.getDate(), deserBean.getDate());
Assert.assertEquals(bean.getStatus(), deserBean.getStatus());
Assert.assertEquals(bean.getType(), deserBean.getType());
Assert.assertEquals(bean.getCollection().size(), deserBean.getCollection().size());
Assert.assertEquals(bean.getCollection().iterator().next().getClass(),
deserBean.getCollection().iterator().next().getClass());
Assert.assertEquals(bean.getAddresses().size(), deserBean.getAddresses().size());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getKey(),
deserBean.getAddresses().entrySet().iterator().next().getKey());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getValue().getClass(),
deserBean.getAddresses().entrySet().iterator().next().getValue().getClass());
}
示例12
@Test
public void testDeserializeBean() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor beanDescriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Object deser = JavaBeanSerializeUtil.deserialize(beanDescriptor);
Assert.assertTrue(deser instanceof Bean);
Bean deserBean = (Bean)deser;
Assert.assertEquals(bean.getDate(), deserBean.getDate());
Assert.assertEquals(bean.getStatus(), deserBean.getStatus());
Assert.assertEquals(bean.getType(), deserBean.getType());
Assert.assertEquals(bean.getCollection().size(), deserBean.getCollection().size());
Assert.assertEquals(bean.getCollection().iterator().next().getClass(),
deserBean.getCollection().iterator().next().getClass());
Assert.assertEquals(bean.getAddresses().size(), deserBean.getAddresses().size());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getKey(),
deserBean.getAddresses().entrySet().iterator().next().getKey());
Assert.assertEquals(bean.getAddresses().entrySet().iterator().next().getValue().getClass(),
deserBean.getAddresses().entrySet().iterator().next().getValue().getClass());
}
示例13
public Phone[] getArray() {
return array;
}
示例14
public void setArray(Phone[] array) {
this.array = array;
}
示例15
public Collection<Phone> getCollection() {
return collection;
}
示例16
public void setCollection(Collection<Phone> collection) {
this.collection = collection;
}
示例17
@Test
public void testBeanSerialize() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Assert.assertTrue(descriptor.isBeanType());
assertEqualsPrimitive(bean.getDate(), descriptor.getProperty("date"));
assertEqualsEnum(bean.getStatus(), descriptor.getProperty("status"));
Assert.assertTrue(((JavaBeanDescriptor) descriptor.getProperty("type")).isClassType());
Assert.assertEquals(Bean.class.getName(), ((JavaBeanDescriptor) descriptor.getProperty("type")).getClassNameProperty());
Assert.assertTrue(((JavaBeanDescriptor) descriptor.getProperty("array")).isArrayType());
Assert.assertEquals(0, ((JavaBeanDescriptor) descriptor.getProperty("array")).propertySize());
JavaBeanDescriptor property = (JavaBeanDescriptor) descriptor.getProperty("collection");
Assert.assertTrue(property.isCollectionType());
Assert.assertEquals(1, property.propertySize());
property = (JavaBeanDescriptor) property.getProperty(0);
Assert.assertTrue(property.isBeanType());
Assert.assertEquals(Phone.class.getName(), property.getClassName());
Assert.assertEquals(0, property.propertySize());
property = (JavaBeanDescriptor) descriptor.getProperty("addresses");
Assert.assertTrue(property.isMapType());
Assert.assertEquals(bean.getAddresses().getClass().getName(), property.getClassName());
Assert.assertEquals(1, property.propertySize());
Map.Entry<Object, Object> entry = property.iterator().next();
Assert.assertTrue(((JavaBeanDescriptor) entry.getKey()).isPrimitiveType());
Assert.assertEquals("first", ((JavaBeanDescriptor) entry.getKey()).getPrimitiveProperty());
Assert.assertTrue(((JavaBeanDescriptor) entry.getValue()).isBeanType());
Assert.assertEquals(FullAddress.class.getName(), ((JavaBeanDescriptor) entry.getValue()).getClassName());
Assert.assertEquals(0, ((JavaBeanDescriptor) entry.getValue()).propertySize());
}
示例18
public Phone[] getArray() {
return array;
}
示例19
public void setArray(Phone[] array) {
this.array = array;
}
示例20
public Collection<Phone> getCollection() {
return collection;
}
示例21
public void setCollection(Collection<Phone> collection) {
this.collection = collection;
}
示例22
@Test
public void testBeanSerialize() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Assert.assertTrue(descriptor.isBeanType());
assertEqualsPrimitive(bean.getDate(), descriptor.getProperty("date"));
assertEqualsEnum(bean.getStatus(), descriptor.getProperty("status"));
Assert.assertTrue(((JavaBeanDescriptor)descriptor.getProperty("type")).isClassType());
Assert.assertEquals(Bean.class.getName(), ((JavaBeanDescriptor)descriptor.getProperty("type")).getClassNameProperty());
Assert.assertTrue(((JavaBeanDescriptor)descriptor.getProperty("array")).isArrayType());
Assert.assertEquals(0, ((JavaBeanDescriptor)descriptor.getProperty("array")).propertySize());
JavaBeanDescriptor property = (JavaBeanDescriptor)descriptor.getProperty("collection");
Assert.assertTrue(property.isCollectionType());
Assert.assertEquals(1, property.propertySize());
property = (JavaBeanDescriptor)property.getProperty(0);
Assert.assertTrue(property.isBeanType());
Assert.assertEquals(Phone.class.getName(), property.getClassName());
Assert.assertEquals(0, property.propertySize());
property = (JavaBeanDescriptor)descriptor.getProperty("addresses");
Assert.assertTrue(property.isMapType());
Assert.assertEquals(bean.getAddresses().getClass().getName(), property.getClassName());
Assert.assertEquals(1, property.propertySize());
Map.Entry<Object, Object> entry = property.iterator().next();
Assert.assertTrue(((JavaBeanDescriptor)entry.getKey()).isPrimitiveType());
Assert.assertEquals("first", ((JavaBeanDescriptor)entry.getKey()).getPrimitiveProperty());
Assert.assertTrue(((JavaBeanDescriptor)entry.getValue()).isBeanType());
Assert.assertEquals(FullAddress.class.getName(), ((JavaBeanDescriptor)entry.getValue()).getClassName());
Assert.assertEquals(0, ((JavaBeanDescriptor)entry.getValue()).propertySize());
}
示例23
public Phone[] getArray() {
return array;
}
示例24
public void setArray(Phone[] array) {
this.array = array;
}
示例25
public Collection<Phone> getCollection() {
return collection;
}
示例26
public void setCollection(Collection<Phone> collection) {
this.collection = collection;
}
示例27
@Test
public void testBeanSerialize() throws Exception {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
bean.setType(Bean.class);
bean.setArray(new Phone[]{});
Collection<Phone> collection = new ArrayList<Phone>();
bean.setCollection(collection);
Phone phone = new Phone();
collection.add(phone);
Map<String, FullAddress> map = new HashMap<String, FullAddress>();
FullAddress address = new FullAddress();
map.put("first", address);
bean.setAddresses(map);
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
Assert.assertTrue(descriptor.isBeanType());
assertEqualsPrimitive(bean.getDate(), descriptor.getProperty("date"));
assertEqualsEnum(bean.getStatus(), descriptor.getProperty("status"));
Assert.assertTrue(((JavaBeanDescriptor)descriptor.getProperty("type")).isClassType());
Assert.assertEquals(Bean.class.getName(), ((JavaBeanDescriptor)descriptor.getProperty("type")).getClassNameProperty());
Assert.assertTrue(((JavaBeanDescriptor)descriptor.getProperty("array")).isArrayType());
Assert.assertEquals(0, ((JavaBeanDescriptor)descriptor.getProperty("array")).propertySize());
JavaBeanDescriptor property = (JavaBeanDescriptor)descriptor.getProperty("collection");
Assert.assertTrue(property.isCollectionType());
Assert.assertEquals(1, property.propertySize());
property = (JavaBeanDescriptor)property.getProperty(0);
Assert.assertTrue(property.isBeanType());
Assert.assertEquals(Phone.class.getName(), property.getClassName());
Assert.assertEquals(0, property.propertySize());
property = (JavaBeanDescriptor)descriptor.getProperty("addresses");
Assert.assertTrue(property.isMapType());
Assert.assertEquals(bean.getAddresses().getClass().getName(), property.getClassName());
Assert.assertEquals(1, property.propertySize());
Map.Entry<Object, Object> entry = property.iterator().next();
Assert.assertTrue(((JavaBeanDescriptor)entry.getKey()).isPrimitiveType());
Assert.assertEquals("first", ((JavaBeanDescriptor)entry.getKey()).getPrimitiveProperty());
Assert.assertTrue(((JavaBeanDescriptor)entry.getValue()).isBeanType());
Assert.assertEquals(FullAddress.class.getName(), ((JavaBeanDescriptor)entry.getValue()).getClassName());
Assert.assertEquals(0, ((JavaBeanDescriptor)entry.getValue()).propertySize());
}
示例28
public Phone[] getArray() {
return array;
}
示例29
public void setArray(Phone[] array) {
this.array = array;
}
示例30
public Collection<Phone> getCollection() {
return collection;
}