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

us.bpsm.edn.parser.DefaultListFactory Maven / Gradle / Ivy

// (c) 2012 B Smith-Mannschott -- Distributed under the Eclipse Public License
package us.bpsm.edn.parser;

import java.io.Serializable;
import java.util.*;

final class DefaultListFactory implements CollectionBuilder.Factory {
    public CollectionBuilder builder() {
        return new CollectionBuilder() {
            ArrayList list = new ArrayList();
            public void add(Object o) {
                list.add(o);
            }
            public Object build() {
                return new DelegatingList(list);
            }
        };
    }
}

final class DelegatingList extends AbstractList implements Serializable {
    final List delegate;

    DelegatingList(List delegate) {
        this.delegate = delegate;
    }

    @Override
    public int size() {
        return delegate.size();
    }

    @Override
    public E get(int index) {
        return delegate.get(index);
    }

}