public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final String value = reader.getValue();
final String[] strings = value.split(" ");
if (strings.length == 1) {
return new Amount(Integer.parseInt(strings[0]), Unit.PIECES);
} else if (strings[1].trim().equalsIgnoreCase("gr")) {
return new Amount(Integer.parseInt(strings[0]), Unit.GRAMS);
} else {
throw new IllegalArgumentException("Could not parse Amount: " + value);
}
}