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

com.github.tomakehurst.wiremock.common.ListFunctions Maven / Gradle / Ivy

package com.github.tomakehurst.wiremock.common;

import java.util.ArrayList;
import java.util.List;

public final class ListFunctions {

    public static  Pair, List> splitByType(A[] items, Class subType) {
        List as = new ArrayList<>();
        List bs = new ArrayList<>();
        for (A a : items) {
            if (subType.isAssignableFrom(a.getClass())) {
                bs.add((B) a);
            } else {
                as.add(a);
            }
        }
        return new Pair<>(as, bs);
    }

    private ListFunctions() {
        throw new UnsupportedOperationException("Not instantiable");
    }
}