Topics

Morphing Objects
Asserting array equality

Morphing Objects

Morphing Objects is as easy as calling morph() on a Morpher or ObjectMorpher . You may have noticed that Morpher does not have a morph() method but ObjectMorpher does, that is because Morpher is used on primitive Morphers too.

Example:

EZMorph comes with a handy class for working with Morphers named MorpherRegistry. It works much like ConvertUtils on commons-beanutils. This class is not a singleton like ConvertUtils, so it is possible to have multiple registries with different Morphers that support the same target class, but take different default values or support different source classes. Another convenient class is MorphUtils, you can register standard Morphers to any MorpherRegistry with it.

Example:

Asserting array equality

Asserting array equality is very easy with ArrayAssertions, just call assertEquals on it, and will try to see first if the arrays reffer to the same location in memory, if not, it will compare them by value, iterating through each dimension the arrays may have.

Here are the meat and bones of every assertEquals: assertEquals( Object[], Object[] ) is different, as it will inspect the arrays for primitive contents and call the appropriate method.