//So it seems easier to add just one if/else.
//If a serializer evolves further a switch to the strategy pattern might be done. A simple map holding the strategies should do it.
//The common case - current version
if ( formatVersion.equals( new Version( 1, 0, 1 ) ) ) {
int cents = Integer.parseInt( deserializeFrom.getAttributeValue( null, "cents" ) );
//We have to close the tag! Every stax based serializer has to close its tag
//getText does this automatically for us. But when only using attributes, we have to close it manually.
closeTag( deserializeFrom );
return new Money( cents );
//The old format that does not use an attribute but text instead
} else if ( formatVersion.equals( new Version( 1, 0, 0 ) ) ) {
int cents = Integer.parseInt( getText( deserializeFrom ) );
//We don't have to close the tag. The getText method does that for us
return new Money( cents );