Type-safe Changed Properties

Overview

Joist automatically tracks dirty and original values in domain objects.

Besides knowing what has changed, it also exposes them in a type-safe API.

For example, given a Domain Object foo, the API for checking whether foo’s name has changed is: foo.getChanged().hasName().

The getChanged() method is used because:

Example

    Parent p = Parent.queries.find(2);

    // Name was foo
    assertEquals("foo", p.getName());

    // Change it to bar
    p.setName("bar");

    // Seesthat name has changed
    assertTrue(p.getChanged().hasName());

    // Get the original name
    assertEquals("foo", p.getChanged().getOriginalName());