code: @Override
      public void writeExternal(ObjectOutput out) throws IOException {
          out.writeByte(type);
          switch (type) {
              case BIG_MONEY: {
                  BigMoney obj = (BigMoney) object;
                  writeBigMoney(out, obj);
                  return;
              }
              case MONEY: {
                  Money obj = (Money) object;
                  writeBigMoney(out, obj.toBigMoney());
                  return;
              }
              case CURRENCY_UNIT: {
                  CurrencyUnit obj = (CurrencyUnit) object;
                  writeCurrency(out, obj);
                  return;
              }
          }
          throw new InvalidClassException("Joda-Money bug: Serialization broken");
      }
docs: Outputs the data.
  
  @serialData One byte type code, then data specific to the type.
  @param out  the output stream
  @throws IOException if an error occurs