Apache Commons BeanUtils: Difference between revisions

Content deleted Content added
 
(3 intermediate revisions by 3 users not shown)
Line 18:
}}
 
'''Apache Commons BeanUtils''' is a [[Java platform|Java]]-based utility to provide [[Component-based software engineering|component based architecture]].<ref name=":0">{{Cite web|url=https://commons.apache.org/proper/commons-beanutils/index.html|title=BeanUtils – Commons|website=commons.apache.org|access-date=2019-08-20}}</ref><ref>{{Cite book|url=https://books.google.co.ukcom/books?id=g2K2zBZWf0wC|title=Building and Testing with Gradle|lastlast1=Berglund|firstfirst1=Tim|last2=McCullough|first2=Matthew|date=2011-07-13|publisher="O'Reilly Media, Inc."|year=|isbn=9781449304638|___location=|pages=57|language=en}}</ref><ref>{{Cite book|url=https://books.google.co.ukcom/books?id=cBvZ4s72Z0gC|title=Maven: The Definitive Guide: The Definitive Guide|last=Company|first=Sonatype|date=2008-09-24|publisher="O'Reilly Media, Inc."|year=|isbn=9780596551780|___location=|pages=136|language=en}}</ref>
 
== Modules ==
Line 29:
== Example ==
Sample code may look like as follows:
<sourcesyntaxhighlight lang="java">
/**
* Example displaying the new default behaviour such that
Line 36:
*/
public void testSuppressClassPropertyByDefault() throws Exception {
final BeanUtilsBean bub = new BeanUtilsBean();
final AlphaBean bean = new AlphaBean();
try {
bub.getProperty(bean, "class");
fail("Could access class property!");
} catch (final NoSuchMethodException ex) {
// okOk
}
}
 
Line 52:
*/
public void testAllowAccessToClassProperty() throws Exception {
final BeanUtilsBean bub = new BeanUtilsBean();
bub.getPropertyUtils().removeBeanIntrospector(SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);
final AlphaBean bean = new AlphaBean();
String result = bub.getProperty(bean, "class");
assertEquals("Class property should have been accessed", "class org.apache.commons.beanutils2.AlphaBean", result);
}
</sourcesyntaxhighlight><ref name=":0" />
 
== See also ==
Line 78:
[[Category:Free software programmed in Java (programming language)]]
[[Category:Software using the Apache license]]
[[Category:Apache Commons|BeanUtils]]