Library supporting a variety of methods for defining bindings between classes and their String representation
Jadira Bindings is a framework for data binding artibrary Java objects to and from one object representation to another. Other libraries provide similar functionality, including: Joda Convert, Apache Commons Convert. Jadira Bindings differs from these frameworks in its functionality and intent.
Unlike other frameworks which typically only register bindings by type, Jadira Bindings supports qualifying bindings according to context. Why would you want to this? Consider the example of a date. The binding selected for database representation would need to be different from that selected for XML Schema. Jadira Bindings supports such distinctions by the use of qualifiers. The qualifier mechanism will be familiar to anyone that has used CDI.
Key features of Jadira Bindings include:
The simplest use of bindings is to mark up to and from methods on the target class and use bindings to invoke them
Just mark up an object method as @To and a constructor or static method with an input object parameter as @From.
A To or From method can be assigned a scope by attaching a qualifier. A qualifier is a special annotation that can be defined and attached to the method. Refer to the Javadoc for org.jadira.bindings.core.annotation.BindingScope. When you don't supply an explicit qualifier, a method is assumed to belong to the qualifier scope org.jadira.bindings.core.annotation.DefaultBinding. The Binder interface provides versions of the convertTo method that accept a qualifier as an additional parameter.
Other than the previously mentioned annotations there are other ways to implement converters
You can use bindings.xml to declaratively reference converter methods which don't have to be defined on the class they convert for - refer to the XSD
A variety of bootstrap mechanisms support loading of the framework as am alternative to directly constructing BasicStringBinder
Bindings supports the Service Loader mechanism in JDK 1.6 for the service named org.jadira.bindings.core.Binder
In CDI environments bindings supports an automatic bootstrap mechanism that scans any beans loaded for bindings or annotated methods