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

com.zipwhip.util.SetDirectory Maven / Gradle / Ivy

package com.zipwhip.util;

import com.zipwhip.lifecycle.DestroyableBase;

import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: jed
 * Date: 9/26/11
 * Time: 10:50 AM
 */
public class SetDirectory extends GenericLocalDirectory {

    public SetDirectory() {
        super(new Factory>() {
            @Override
            public Collection create() throws Exception {
                return Collections.synchronizedSet(new TreeSet(COMPARATOR));
            }
        });
    }

    public SetDirectory(Collection values, InputCallable sorter) {
        this();

        if (CollectionUtil.isNullOrEmpty(values)){
            return;
        }
        if (sorter == null){
            throw new NullPointerException("Need to have a sorter");
        }

        synchronized (values) {
            for(TValue value : values){
                TKey key = sorter.call(value);

                add(key, value);
            }
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy