Package org.nuiton.util.beans
Packages for all stuff of bean transformations (binder, and others...).
This package contains two api :
This object permits to listen javaBeans and keep modifications made on a bean.
More explanations will come soon, meanwhile you can see the test class :
- the Binder api to copy objects
- Some javabeans compiliant api
The Binder api
This api permits to some object properties from an object to another one.
Obtain a binder
A Binder contains a safe model named
Binder.BinderModel which knows
all properties that can be copied.
Binder
object from the BinderFactory like this :
Binder<A, A> binder = BinderFactory.newBinder(A.class);It is also possible to build a more sofisticated binder which will only copy some properties, using the
BinderModelBuilder.
Use a binder
Once you have a binder, you use theBinder api :
To copy all properties from an object to another one :
binder.copy(source, target);To copy just some properties from an object to another one :
binder.copy(source, target, "propertyOne", "propertyTwo");To copy all properties except some :
binder.copyExcluding(source, target, "propertyToExeclude");To obtain some properties from an object, use the following code :
Map<String, Object> properties = binder.obtainProperties(source, "propertyOne", "propertyTwo");
Building a new BinderModel
In two words, you have to use the
BinderModelBuilder object to do this.
then register your binder model into the
BinderFactory using one of the method
org.nuiton.util.beans.BinderFactory#registerBinderModel(XXX).
You can go and look on the unit tests which describe it pretty well :) :
org.nuiton.util.beans.BinderModelBuilderTest
JavaBeans api
BeanMonitor class
This object permits to listen javaBeans and keep modifications made on a bean.
More explanations will come soon, meanwhile you can see the test class :
org.nuiton.util.beans.BeanMonitorTest
- Since:
- 1.1.5
-
Interface Summary Interface Description InstanceFactory<O> -
Class Summary Class Description BeanMonitor A monitor of beans.BeanUtil Usefull methods around thePropertyChangeListener.Binder<I,O> Abinderpermits to copy some properties from an object to another one.Binder.BinderModel<S,T> Model of aBinder.BinderFactory Factory ofBinder.BinderFactory.BindelModelEntryMap BinderFactory.BinderModelEntry Definition of an binder model entry (source and target types + context name).BinderModelBuilder<S,T> Class to create a newBinder.BinderModel.PropertyDiff TODO -
Enum Summary Enum Description Binder.CollectionStrategy Types of loading of collections.