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

com.natpryce.makeiteasy.NewCollectionDonor Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
package com.natpryce.makeiteasy;

import java.util.Collection;

import static java.util.Arrays.asList;

public abstract class NewCollectionDonor, E> implements Donor {
    private final Iterable> elementDonors;

    @SafeVarargs
    public NewCollectionDonor(Donor... elementDonors) {
        this(asList(elementDonors));
    }

    public NewCollectionDonor(Iterable> elementDonors) {
        this.elementDonors = elementDonors;
    }

    @Override
    public T value() {
        T newCollection = newCollection();
        for (Donor elementDonor : elementDonors) {
            newCollection.add(elementDonor.value());
        }
        return newCollection;
    }

    protected abstract T newCollection();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy