/** * Writes the primitive value to the stream. * * @param out A stream to write to. * @param value A value to write. * @throws IOException If an I/O error occurs. */ static void writePrimitive(DataOutput out, Object value) throws IOException { if (value instanceof Byte) out.writeByte((Byte) value); else if (value instanceof Short) out.writeShort((Short) value); else if (value instanceof Integer) out.writeInt((Integer) value); else if (value instanceof Long) out.writeLong((Long) value); else if (value instanceof Float) out.writeFloat((Float) value); else if (value instanceof Double) out.writeDouble((Double) value); else if (value instanceof Boolean) out.writeBoolean((Boolean) value); else if (value instanceof Character) out.writeChar((Character) value); else throw new IllegalArgumentException(); }