code: private byte[] toByteArray(Object val) {
          if (val == null)
              return null;
          if (val instanceof byte[])
              return (byte[]) val;
          if (val instanceof ByteBuffer) {
              // Defensive code but execution should never get here. The internal
              // representation of binary should always be
              // byte[], not ByteBuffer. This allows Item to be converted into
              // a JSON string via Jackson without causing trouble.
              return copyAllBytesFrom((ByteBuffer)val);
          }
          throw new IncompatibleTypeException(val.getClass()
                  + " cannot be converted into a byte array");
      }
docs: This method is assumed to be only called from a getter method, but NOT
  from a setter method.