Prevent possible NPE in Quantity.hashCode()