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

net.jqwik.vavr.arbitraries.collection.map.VavrTreeMapArbitrary Maven / Gradle / Ivy

package net.jqwik.vavr.arbitraries.collection.map;

import net.jqwik.vavr.NaturalComparator;
import net.jqwik.vavr.arbitraries.base.MapBasedArbitrary;
import io.vavr.collection.TreeMap;
import net.jqwik.api.Arbitrary;

import java.util.Comparator;
import java.util.Map;

/**
 * @author Benno Müller
 */
public class VavrTreeMapArbitrary extends MapBasedArbitrary> {

    private final Comparator keyComparator;

    public VavrTreeMapArbitrary(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary,
            final Comparator keyComparator) {
        super(keysArbitrary, valuesArbitrary);
        this.keyComparator = keyComparator;
    }

    public VavrTreeMapArbitrary(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        this(keysArbitrary, valuesArbitrary, NaturalComparator.instance());
    }

    @Override
    protected TreeMap convertJavaMapToVavrMap(Map javaMap) {
        return TreeMap.ofAll(this.keyComparator, javaMap);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy