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

com.alphasystem.docx4j.builder.wml.RBuilder 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.R;
import org.docx4j.wml.RPr;


/**
 * Fluent API builder for org.docx4j.wml.R.
 * 
 */
public class RBuilder
    extends OpenXmlBuilder
{


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

    /**
     * Initialize the builder with given object.
     * 
     * @param object
     *     the given object
     */
    public RBuilder(R 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 RBuilder(R src, R target) {
        this(target);
        if (src!= null) {
            RPr rPr = src.getRPr();
            if (rPr!= null) {
                rPr = new RPrBuilder(rPr, object.getRPr()).getObject();
            }
            List content = src.getContent();
            for (Object o: content) {
                addContent(WmlBuilderFactory.cloneObject(o));
            }
            withRPr(rPr).withRsidRPr(src.getRsidRPr()).withRsidDel(src.getRsidDel()).withRsidR(src.getRsidR());
        }
    }

    protected R createObject() {
        return WmlBuilderFactory.OBJECT_FACTORY.createR();
    }

    public RBuilder withRPr(RPr value) {
        if (value!= null) {
            object.setRPr(value);
        }
        return this;
    }

    public RBuilder addContent(Object... value) {
        addContent(object.getContent(), value);
        return this;
    }

    public RBuilder withRsidRPr(String value) {
        if (value!= null) {
            object.setRsidRPr(value);
        }
        return this;
    }

    public RBuilder withRsidDel(String value) {
        if (value!= null) {
            object.setRsidDel(value);
        }
        return this;
    }

    public RBuilder withRsidR(String value) {
        if (value!= null) {
            object.setRsidR(value);
        }
        return this;
    }

}