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

net.maizegenetics.taxa.TaxaList Maven / Gradle / Ivy

Go to download

TASSEL 6 is a software package to evaluate traits association. Feature Tables are at the heart of the package where, a feature is a range of positions or a single position. Row in the that table are taxon.

There is a newer version: 6.0.1
Show newest version
/*
 *  TaxaList
 */
package net.maizegenetics.taxa;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;

/**
 *
 * @author Terry Casstevens
 */
public interface TaxaList extends List {

    /**
     * Returns number of taxa
     *
     * @return number of taxa
     */
    public int numberOfTaxa();

    /**
     * Return taxa name at given index.
     *
     * @param index
     *
     * @return taxa name
     */
    public String taxaName(int index);

    /**
     * Return a list of all matching taxa indices for a given name.
     *
     * @param name name
     *
     * @return Indices for matching taxa (-1 if no match).
     */
    public int indexOf(String name);

    /**
     * Return a list of all matching taxa indices for a given name.
     *
     * @param taxon taxon
     *
     * @return Indices for matching taxa (-1 if no match).
     */
    public int indexOf(Taxon taxon);

    /**
     * Returns TaxaList Collector.
     * 
     * @return collector 
     */
    public static Collector collect() {
        return new TaxaListCollector();
    }

    public static class TaxaListCollector implements Collector {

        @Override
        public Supplier supplier() {
            return TaxaListBuilder::new;
        }

        @Override
        public BiConsumer accumulator() {
            return TaxaListBuilder::add;
        }

        @Override
        public BinaryOperator combiner() {
            return (left, right) -> {
                left.addAll(right);
                return left;
            };
        }

        @Override
        public Function finisher() {
            return TaxaListBuilder::build;
        }

        @Override
        public Set characteristics() {
            return Collections.EMPTY_SET;
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy