public MultipartBuilder copy()

in dom/src/main/java/org/apache/james/mime4j/message/MultipartBuilder.java [255:289]


    public MultipartBuilder copy(Multipart other) {
        if (other == null) {
            return this;
        }
        subType = other.getSubType();
        bodyParts.clear();
        final List<Entity> otherParts = other.getBodyParts();
        for (Entity otherPart: otherParts) {
            BodyPart bodyPart = new BodyPart();
            Header otherHeader = otherPart.getHeader();
            if (otherHeader != null) {
                HeaderImpl header = new HeaderImpl();
                for (Field otherField : otherHeader.getFields()) {
                    header.addField(otherField);
                }
                bodyPart.setHeader(header);
            }
            final Body otherBody = otherPart.getBody();
            if (otherBody != null) {
                Body body = null;
                if (otherBody instanceof Message) {
                    body = MessageBuilder.createCopy((Message) otherBody).build();
                } else if (otherBody instanceof Multipart) {
                    body = MultipartBuilder.createCopy((Multipart) otherBody).build();
                } else if (otherBody instanceof SingleBody) {
                    body = ((SingleBody) otherBody).copy();
                }
                bodyPart.setBody(body);
            }
            bodyParts.add(bodyPart);
        }
        preamble = other.getPreamble();
        epilogue = other.getEpilogue();
        return this;
    }