package com.axellience.vuegwt.client.vnode.builder;

import com.axellience.vuegwt.client.VueGWT;
import com.axellience.vuegwt.client.component.VueComponent;
import com.axellience.vuegwt.client.vnode.VNode;
import com.axellience.vuegwt.client.vnode.VNodeData;
import com.axellience.vuegwt.client.vue.VueFactory;
import com.axellience.vuegwt.client.vue.VueJsConstructor;

/**
 * @author Adrien Baron
 */
public class VNodeBuilder
{
    private final CreateElementFunction function;

    public VNodeBuilder(CreateElementFunction function)
    {
        this.function = function;
    }

    /**
     * Create an empty VNode
     * @return a new empty VNode
     */
    public VNode el()
    {
        return this.function.create(null, null, null);
    }

    /**
     * Create a VNode with the given HTML tag
     * @param tag HTML tag for the new VNode
     * @param children Children
     * @return a new VNode of this tag
     */
    public VNode el(String tag, Object... children)
    {
        return this.function.create(tag, children, null);
    }

    /**
     * Create a VNode with the given HTML tag
     * @param tag HTML tag for the new VNode
     * @param data Information for the new VNode (attributes...)
     * @param children Children
     * @return a new VNode of this tag
     */
    public VNode el(String tag, VNodeData data, Object... children)
    {
        return this.function.create(tag, data, children);
    }

    /**
     * Create a VNode with the given {@link VueComponent}
     * @param vueComponentClass Class for the {@link VueComponent} we want
     * @param data Information for the new VNode (attributes...)
     * @param children Children
     * @return a new VNode of this Component
     */
    public VNode el(Class<VueComponent> vueComponentClass, VNodeData data, Object... children)
    {
        return el(VueGWT.getJsConstructor(vueComponentClass), data, children);
    }

    /**
     * Create a VNode with the {@link VueComponent} of the given {@link VueFactory}
     * @param vueFactory {@link VueFactory} for the Component we want
     * @param children Children
     * @return a new VNode of this Component
     */
    public VNode el(VueFactory<VueComponent> vueFactory, Object... children)
    {
        return el(vueFactory.getJsConstructor(), children, null);
    }

    /**
     * Create a VNode with the {@link VueComponent} of the given {@link VueJsConstructor}
     * @param vueJsConstructor {@link VueJsConstructor} for the Component we want
     * @param children Children
     * @return a new VNode of this Component
     */
    public VNode el(VueJsConstructor<VueComponent> vueJsConstructor, Object... children)
    {
        return this.function.create(vueJsConstructor, children, null);
    }
}

@@ -1420,32 +1420,437 @@
 ildren);%0A    %7D%0A%0A
+    /**%0A     * Create a VNode with the given %7B@link VueComponent%7D%0A     * @param vueComponentClass Class for the %7B@link VueComponent%7D we want%0A     * @param children Children%0A     * @return a new VNode of this Component%0A     */%0A    public %3CT extends VueComponent%3E VNode el(Class%3CT%3E vueComponentClass, Object... children)%0A    %7B%0A        return el(VueGWT.getJsConstructor(vueComponentClass), children);%0A    %7D%0A%0A
     /**%0A     * C
@@ -2139,35 +2139,49 @@
 lic 
-VNode el(Class%3CVueComponent
+%3CT extends VueComponent%3E VNode el(Class%3CT
 %3E vu
@@ -2587,52 +2587,564 @@
 lic 
-VNode el(VueFactory%3CVueComponent%3E vueFactory
+%3CT extends VueComponent%3E VNode el(VueFactory%3CT%3E vueFactory, Object... children)%0A    %7B%0A        return el(vueFactory.getJsConstructor(), children, null);%0A    %7D%0A%0A    /**%0A     * Create a VNode with the %7B@link VueComponent%7D of the given %7B@link VueFactory%7D%0A     * @param vueFactory %7B@link VueFactory%7D for the Component we want%0A     * @param data Information for the new VNode (attributes...)%0A     * @param children Children%0A     * @return a new VNode of this Component%0A     */%0A    public %3CT extends VueComponent%3E VNode el(VueFactory%3CT%3E vueFactory, VNodeData data
 , Ob
@@ -3207,32 +3207,38 @@
 JsConstructor(),
+ data,
  children, null)
@@ -3222,38 +3222,32 @@
 , data, children
-, null
 );%0A    %7D%0A%0A    /*
@@ -3507,32 +3507,57 @@
    */%0A    public
+ %3CT extends VueComponent%3E
  VNode el(VueJsC
@@ -3567,28 +3567,516 @@
 tructor%3C
-VueComponent
+T%3E vueJsConstructor, Object... children)%0A    %7B%0A        return el(vueJsConstructor, null, children);%0A    %7D%0A%0A    /**%0A     * Create a VNode with the %7B@link VueComponent%7D of the given %7B@link VueJsConstructor%7D%0A     * @param vueJsConstructor %7B@link VueJsConstructor%7D for the Component we want%0A     * @param data Information for the new VNode (attributes...)%0A     * @param children Children%0A     * @return a new VNode of this Component%0A     */%0A    public %3CT extends VueComponent%3E VNode el(VueJsConstructor%3CT
 %3E vueJsC
@@ -4078,32 +4078,48 @@
 ueJsConstructor,
+ VNodeData data,
  Object... child
@@ -4182,16 +4182,22 @@
 tructor,
+ data,
  childre
@@ -4189,33 +4189,27 @@
 , data, children
-, null
 );%0A    %7D%0A%7D%0A

Add support for vueComponentClass in VNodeBuilder