public void write(Packer pk, List<E> target, boolean required)
            throws IOException {
        if (!(target instanceof List)) {
            if (target == null) {
                if (required) {
                    throw new MessageTypeException("Attempted to write null");
                }
                pk.writeNil();
                return;
            }
            throw new MessageTypeException("Target is not a List but "
                    + target.getClass());
        }
        pk.writeArrayBegin(target.size());
        for (E e : target) {
            elementTemplate.write(pk, e);
        }
        pk.writeArrayEnd();
    }