@@ -0,0 +1,2542 @@
+package com.wizzardo.tools.misc.pool;%0A%0Aimport java.util.LinkedList;%0Aimport java.util.Queue;%0A%0A/**%0A * Created by wizzardo on 30.06.15.%0A */%0Apublic class PoolBuilder%3CT%3E %7B%0A%0A    protected Supplier%3CT%3E supplier = new Supplier%3CT%3E() %7B%0A        @Override%0A        public T get() %7B%0A            return null;%0A        %7D%0A    %7D;%0A%0A    protected Resetter%3CT%3E resetter = new Resetter%3CT%3E() %7B%0A        @Override%0A        public T reset(T t) %7B%0A            return t;%0A        %7D%0A    %7D;%0A%0A    protected HolderSupplier%3CT%3E holderSupplier = new HolderSupplier%3CT%3E() %7B%0A        @Override%0A        public Holder%3CT%3E get(Pool%3CT%3E pool, T value, final Resetter%3CT%3E resetter) %7B%0A            return new SoftHolder%3CT%3E(pool, value) %7B%0A                @Override%0A                public T get() %7B%0A                    return resetter.reset(super.get());%0A                %7D%0A            %7D;%0A        %7D%0A    %7D;%0A%0A    protected Supplier%3CQueue%3CHolder%3CT%3E%3E%3E queueSupplier = new Supplier%3CQueue%3CHolder%3CT%3E%3E%3E() %7B%0A        ThreadLocal%3CQueue%3CHolder%3CT%3E%3E%3E queue = new ThreadLocal%3CQueue%3CHolder%3CT%3E%3E%3E() %7B%0A            @Override%0A            protected Queue%3CHolder%3CT%3E%3E initialValue() %7B%0A                return new LinkedList%3CHolder%3CT%3E%3E();%0A            %7D%0A        %7D;%0A%0A        @Override%0A        public Queue%3CHolder%3CT%3E%3E get() %7B%0A            return queue.get();%0A        %7D%0A    %7D;%0A%0A    public PoolBuilder%3CT%3E queue(Supplier%3CQueue%3CHolder%3CT%3E%3E%3E queueSupplier) %7B%0A        this.queueSupplier = queueSupplier;%0A        return this;%0A    %7D%0A%0A    public PoolBuilder%3CT%3E holder(HolderSupplier%3CT%3E holderSupplier) %7B%0A        this.holderSupplier = holderSupplier;%0A        return this;%0A    %7D%0A%0A    public PoolBuilder%3CT%3E supplier(Supplier%3CT%3E supplier) %7B%0A        this.supplier = supplier;%0A        return this;%0A    %7D%0A%0A    public PoolBuilder%3CT%3E resetter(Resetter%3CT%3E resetter) %7B%0A        this.resetter = resetter;%0A        return this;%0A    %7D%0A%0A    public Pool%3CT%3E build() %7B%0A        return new AbstractQueuedPool%3CT%3E() %7B%0A            @Override%0A            public T create() %7B%0A                return supplier.get();%0A            %7D%0A%0A            @Override%0A            protected Queue%3CHolder%3CT%3E%3E queue() %7B%0A                return queueSupplier.get();%0A            %7D%0A%0A            @Override%0A            protected Holder%3CT%3E createHolder(T t) %7B%0A                return holderSupplier.get(this, t, resetter);%0A            %7D%0A        %7D;%0A    %7D%0A%0A    public interface Supplier%3CT%3E %7B%0A        T get();%0A    %7D%0A%0A    public interface Resetter%3CT%3E %7B%0A        T reset(T t);%0A    %7D%0A%0A    public interface HolderSupplier%3CT%3E %7B%0A        Holder%3CT%3E get(Pool%3CT%3E pool, T value, Resetter%3CT%3E resetter);%0A    %7D%0A%7D%0A

add PoolBuilder