package cz.req.ax.builders;

import cz.req.ax.AxUtils;
import cz.req.ax.data.AxContainer;

import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author <a href="mailto:jan.pikl@marbes.cz">Jan Pikl</a>
 *         Date: 19.2.2016
 */
public abstract class AxContainerBuilder<ID, BEAN, CONTAINER extends AxContainer<ID, BEAN>> {

    protected Class<ID> idType;
    protected Class<BEAN> beanType;

    public AxContainerBuilder(Class<ID> idType, Class<BEAN> beanType) {
        this.idType = Objects.requireNonNull(idType);
        this.beanType = Objects.requireNonNull(beanType);
    }

    public abstract CONTAINER get();

    public CONTAINER of(Collection<? extends BEAN> collection) {
        CONTAINER container = get();
        container.addAll(collection);
        return container;
    }

    public CONTAINER of(Stream<? extends BEAN> stream) {
        return of(stream.collect(Collectors.toList()));
    }

    public CONTAINER of(BEAN bean, BEAN... otherBeans) {
        return of(AxUtils.concat(bean, otherBeans));
    }

}

@@ -130,23 +130,81 @@
 va.util.
-Objects
+List;%0Aimport java.util.Objects;%0Aimport java.util.stream.Collector
 ;%0Aimport
@@ -996,33 +996,111 @@
     
-return of(stream.
+// Musi byt v promenne, jinak mi to javac neprelozi%0A        Collector%3CBEAN, ?, List%3CBEAN%3E%3E 
 collect
-(
+or = 
 Coll
@@ -1114,16 +1114,60 @@
 toList()
+;%0A        return of(stream.collect(collector
 ));%0A    

Fix javac error