heisgetNestedProperty("">
class="java" name="code"> Person person=new Person(); person.setName=("heis"); String name=(String)PropertyUtils.getSimpleProperty(person,"name");->heis
Book book=new Book(); book.setAuthor(person); String authorName=(String)PropertyUtils.getNestedProperty(book,"author.name");//得到person的name
Chapter chapter1=new Chapter(); Chapter chapter2=new Chapter(); book.getChapters().add(chapter1); book.getChapters().add(chapter2); Chapter chapter=(Chapter)PropertyUtils.getIndexedProperty(book,"chapter[0]");
Person person=new Person(); person.setName=("heis"); Map favorites=new HashMap(); favorites.put("food","rice"); person.setFavorite(favorites); String favorFood=(String)PropertyUtils.getMappedProperty(person,"favorites(food)");->rice
这是一个树型的Bean属性视图 Book book |--List authors |--[0]->Person person |--Map favorites |--Entry(key->"food",value->"") PropertyUtils.setProperty(book,"authors[0].favorites(food)","rice"); String favorFood=(String)PropertyUtils.getProperty(book,"authors[0].favorites(food)");->rice
PropertyUtils.isReadable(book,"name"); PropertyUtils.isWritable(book,"name");
System.out.println(PropertyUtils.getPropertyType(person,"favorites"));->java.util.Map
Book book1=new Book(); book1.setName("Commons Cookbook Notes"); Book book2=new Book(); PropertyUtils.copyProperty(book2,book1);//将book1的name属性copy到book2
Person person=new Person(); person.setName("heis"); Book book=new Book(); book.setName("Commons Cookbook Notes"); book.setAuthor(person); Map propMap=PropertyUtils.describe(book); propMap.get("name");->Commons Cookbook Notes propMap.get("author");->person