All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alphasystem.docx4j.builder.wml.PictBuilder Maven / Gradle / Ivy

There is a newer version: 0.5.5
Show newest version

package com.alphasystem.docx4j.builder.wml;

import java.util.List;
import com.alphasystem.docx4j.builder.OpenXmlBuilder;
import org.docx4j.wml.CTControl;
import org.docx4j.wml.CTRel;
import org.docx4j.wml.Pict;


/**
 * Fluent API builder for org.docx4j.wml.Pict.
 * 
 */
public class PictBuilder
    extends OpenXmlBuilder
{


    /**
     * Initialize the underlying object.
     * 
     */
    public PictBuilder() {
        this(null);
    }

    /**
     * Initialize the builder with given object.
     * 
     * @param object
     *     the given object
     */
    public PictBuilder(Pict object) {
        super(object);
    }

    /**
     * Copies values fom src into target. Values of target will be overridden by the values from src.
     * 
     * @param src
     *     source object
     * @param target
     *     target object
     */
    public PictBuilder(Pict src, Pict target) {
        this(target);
        if (src!= null) {
            CTRel movie = src.getMovie();
            if (movie!= null) {
                movie = new com.alphasystem.docx4j.builder.wml.CTRelBuilder(movie, object.getMovie()).getObject();
            }
            CTControl control = src.getControl();
            if (control!= null) {
                control = new CTControlBuilder(control, object.getControl()).getObject();
            }
            List anyAndAny = src.getAnyAndAny();
            for (Object o: anyAndAny) {
                addAnyAndAny(WmlBuilderFactory.cloneObject(o));
            }
            withMovie(movie).withControl(control).withAnchorId(src.getAnchorId());
        }
    }

    protected Pict createObject() {
        return WmlBuilderFactory.OBJECT_FACTORY.createPict();
    }

    public PictBuilder withMovie(CTRel value) {
        if (value!= null) {
            object.setMovie(value);
        }
        return this;
    }

    public PictBuilder withMovie(String id) {
        if (id!= null) {
            object.setMovie(new com.alphasystem.docx4j.builder.wml.CTRelBuilder().withId(id).getObject());
        }
        return this;
    }

    public PictBuilder withControl(CTControl value) {
        if (value!= null) {
            object.setControl(value);
        }
        return this;
    }

    public PictBuilder withAnchorId(String value) {
        if (value!= null) {
            object.setAnchorId(value);
        }
        return this;
    }

    public PictBuilder addAnyAndAny(Object... value) {
        addContent(object.getAnyAndAny(), value);
        return this;
    }

}