Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

commons beanutils alternative

I am looking for a commons beanutils alternative. The reason is that beanutils relies on commons-logging which is conflicting with existing libraries I am using.

I would like a small self-contained alternative which will cause no/minimal conflicts.

The main functionality I am after is nested property retrieval.

Thanks in advance, Steven

like image 352
Steven Avatar asked Oct 15 '10 06:10

Steven


People also ask

What is Commons BeanUtils used for?

The Java BeanUtils are the components of the Apache Commons which are derived from JavaAPI and provides component architecture for the Java language. The Java BeanUtils design patterns uses utility classes that helps to get and set the property values on Java classes for retrieving and defining the bean properties.

Why we use BeanUtils copyProperties?

Copying properties of one object to another object is often tedious and error-prone for developers. BeanUtils class provides a copyProperties method that copies the properties of source object to target object where the property name is same in both objects.

Does BeanUtils use reflection?

As they both ultimately use Reflection you aren't likely to notice much difference, unless the higher-level API is doing things you don't need done. See also java. beans.


2 Answers

While property handling is not the main focus of Jackson, it can be used for that, as per this article.

The basic idea is that you can not only read/write JSON to/from POJOs, but also do compatible conversions: including that of "serializing" a POJO as a Java Map. Since you can go back and forth between representations you basically get a bean introspector for free.

Jackson has no external dependencies, but you need both core (streaming api, impls) and mapper jars (data binding).

like image 115
StaxMan Avatar answered Oct 21 '22 20:10

StaxMan


Jodd has very good collection of libraries, See if Jodd BeanUtil helps.

like image 5
sojin Avatar answered Oct 21 '22 21:10

sojin