package com.netopyr.reduxfx.vscenegraph.builders;

import com.netopyr.reduxfx.vscenegraph.VNode;
import com.netopyr.reduxfx.vscenegraph.event.VEventHandler;
import com.netopyr.reduxfx.vscenegraph.event.VEventType;
import com.netopyr.reduxfx.vscenegraph.property.VProperty;
import io.vavr.collection.Array;
import io.vavr.collection.Map;
import io.vavr.control.Option;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

@SuppressWarnings("unused")
public class ContextMenuBuilder<B extends ContextMenuBuilder<B>> extends PopupControlBuilder<B> {

    private static final String ITEMS = "items";

    public ContextMenuBuilder(Class<?> nodeClass,
                              Map<String, Array<VNode>> childrenMap,
                              Map<String, Option<VNode>> singleChildMap,
                              Map<String, VProperty> properties,
                              Map<VEventType, VEventHandler> eventHandlers) {
        super(nodeClass, childrenMap, singleChildMap, properties, eventHandlers);
    }

    @SuppressWarnings("unchecked")
    @Override
    protected B create(
            Map<String, Array<VNode>> childrenMap,
            Map<String, Option<VNode>> singleChildMap,
            Map<String, VProperty> properties,
            Map<VEventType, VEventHandler> eventHandlers) {
        return (B) new ContextMenuBuilder<>(getNodeClass(), childrenMap, singleChildMap, properties, eventHandlers);
    }


    public B items(VNode... items) {
        return children(ITEMS, items == null? Array.empty() : Array.of(items));
    }


    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
                .appendSuper(super.toString())
                .toString();
    }
}

@@ -1505,21 +1505,31 @@
 B items(
-VNo
+MenuItemBuil
 de
+r
 ... item

fix type of ContextMenuBuilder items to MenuItemBuilders