Joda Beans

Joda-Beans provides a small framework that adds properties to Java, greatly enhancing JavaBeans. The key concept is to allow each property on a bean to be accessed as an object. This enables technologies such as XPath, XML conversion, DB mappings, WebApp validation and Swing bindings.

By default, Joda-Beans includes a round-trip serialization system to JSON, XML and MsgPack binary. This uses the information encoded in the Joda-Bean as a partial schema for the message.

Version 1.2 is the latest version - Download now

Joda-Beans is licensed under the business-friendly Apache 2.0 licence.

Why Joda Beans?

Joda-Beans has been created to plug a gap in the Java language - properties. The concept of properties is familiar to those coding in almost every other modern language. Java stands alone in its pursuit of the terrible JavaBean approach, and personally I believe that properties should have been added to Java before generics and closures.

JavaBeans are typically created by manual coding or one-off IDE generation, such as by Eclipse. The same approach is taken to the creation of equals and hashCode methods. However, none of these approaches provides for a simple and fast mechanism to query a bean for the properties it exposes.

Joda-Beans provides a solution. As a developer, you just write the fields much as you would today. Then you add annotations to the bean and properties. Finally, you run a code generator, which creates the get/set methods plus framework methods that allow the properties to be effectively queried. A key point is that the code generator may be run again and again on the Java file, and is non-destructive.

 public final class Foo implements Bean {
   /** The forename. */
    private String forename;

    /** The surname. */
    @PropertyDefinition(validate = "notNull")
    private String surname;

    /** The address of the person. */
    private Address address;
   // Joda-Beans will code generate all getters, setters, equals, hashCode, toString and property accessors

See these sample classes used for testing - basic Person class, example usage, example of validation.

As well as mutable beans following the Java Bean specification. Joda-Beans supports the creation of immutable beans. One of the biggest issues with using immutable objects in Java is their creation. Joda-Beans simplifies this by code generating builder classes for each immutable bean:

  // using code generated immutable bean builders, example showing an interest rate swap leg
  FixedRateSwapLeg payLeg = FixedRateSwapLeg.builder()
      .startDate(LocalDate.of(2014, 9, 12))
      .endDate(LocalDate.of(2021, 9, 12))
      .businessDayAdjustment(BusinessDayAdjustment.of(BusinessDayConventions.MODIFIED_FOLLOWING, HolidayCalendars.USNY))
      .notional(NotionalAmount.of(CurrencyAmount.of(Currency.USD, 100_000_000)))

Once beans and properties are defined, it is possible to use them in powerful ways. A fast and efficient serialization mechanism is provided using Joda-Convert for object to string conversion:

  • JSON
  • XML
  • Binary (MsgPack format)

Further integration is included for MongoDB and Freemarker.


Various documentation is available:


Release 1.2 is the current release. This release is considered stable and worthy of the 1.x tag.

The project runs on JDK 1.6 and requires Joda-Convert. There are a number of optional dependencies which help with integration.

Available in Maven Central.


Support on bugs, library usage or enhancement requests is available on a best efforts basis.

To suggest enhancements or contribute, please fork the source code on GitHub. Alternatively, use GitHub issues.