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

net.jqwik.vavr.api.VavrArbitraries Maven / Gradle / Ivy

package net.jqwik.vavr.api;

import net.jqwik.vavr.arbitraries.collection.map.VavrHashMultimapArbitrary;
import net.jqwik.vavr.arbitraries.collection.map.VavrLinkedHashMultimapArbitrary;
import net.jqwik.vavr.arbitraries.collection.map.VavrTreeMultimapArbitrary;
import net.jqwik.vavr.arbitraries.collection.seq.VavrArrayArbitrary;
import net.jqwik.vavr.arbitraries.collection.set.VavrBitSetArbitrary;
import net.jqwik.vavr.arbitraries.collection.seq.VavrCharSeqArbitrary;
import net.jqwik.vavr.arbitraries.control.VavrEitherArbitrary;
import net.jqwik.vavr.arbitraries.concurrent.VavrFutureArbitrary;
import net.jqwik.vavr.arbitraries.collection.map.VavrHashMapArbitrary;
import net.jqwik.vavr.arbitraries.collection.set.VavrHashSetArbitrary;
import net.jqwik.vavr.arbitraries.collection.VavrIteratorArbitrary;
import net.jqwik.vavr.arbitraries.VavrLazyArbitrary;
import net.jqwik.vavr.arbitraries.collection.map.VavrLinkedHashMapArbitrary;
import net.jqwik.vavr.arbitraries.collection.set.VavrLinkedHashSetArbitrary;
import net.jqwik.vavr.arbitraries.collection.seq.VavrListArbitrary;
import net.jqwik.vavr.arbitraries.control.VavrOptionArbitrary;
import net.jqwik.vavr.arbitraries.collection.queue.VavrPriorityQueueArbitrary;
import net.jqwik.vavr.arbitraries.collection.queue.VavrQueueArbitrary;
import net.jqwik.vavr.arbitraries.collection.VavrStreamArbitrary;
import net.jqwik.vavr.arbitraries.collection.VavrTreeArbitrary;
import net.jqwik.vavr.arbitraries.collection.map.VavrTreeMapArbitrary;
import net.jqwik.vavr.arbitraries.collection.set.VavrTreeSetArbitrary;
import net.jqwik.vavr.arbitraries.control.VavrTryArbitrary;
import net.jqwik.vavr.arbitraries.control.VavrValidationArbitrary;
import net.jqwik.vavr.arbitraries.collection.seq.VavrVectorArbitrary;
import io.vavr.collection.Array;
import io.vavr.collection.BitSet;
import io.vavr.collection.CharSeq;
import io.vavr.collection.HashMap;
import io.vavr.collection.HashMultimap;
import io.vavr.collection.HashSet;
import io.vavr.collection.IndexedSeq;
import io.vavr.collection.Iterator;
import io.vavr.collection.LinearSeq;
import io.vavr.collection.LinkedHashMap;
import io.vavr.collection.LinkedHashMultimap;
import io.vavr.collection.LinkedHashSet;
import io.vavr.collection.List;
import io.vavr.collection.Map;
import io.vavr.collection.Multimap;
import io.vavr.collection.PriorityQueue;
import io.vavr.collection.Queue;
import io.vavr.collection.Seq;
import io.vavr.collection.Set;
import io.vavr.collection.SortedMap;
import io.vavr.collection.SortedMultimap;
import io.vavr.collection.Stream;
import io.vavr.collection.Tree;
import io.vavr.collection.TreeMap;
import io.vavr.collection.TreeMultimap;
import io.vavr.collection.TreeSet;
import io.vavr.collection.Vector;
import net.jqwik.api.Arbitrary;
import net.jqwik.api.arbitraries.SizableArbitrary;
import net.jqwik.api.arbitraries.StreamableArbitrary;
import org.apiguardian.api.API;

import java.util.Comparator;

import static org.apiguardian.api.API.Status.STABLE;

@API(status = STABLE, since = "2.0.0")
public final class VavrArbitraries {

    private VavrArbitraries() {
        super();
    }

    /*
     * Classes
     */

    public static  VavrLazyArbitrary lazy(final Arbitrary innerArbitrary) {
        return new VavrLazyArbitrary<>(innerArbitrary);
    }

    public static  VavrOptionArbitrary option(final Arbitrary innerArbitrary) {
        return new VavrOptionArbitrary<>(innerArbitrary.injectNull(0.05));
    }

    public static  VavrEitherArbitrary either(
            final Arbitrary leftArbitrary,
            final Arbitrary rightArbitrary) {
        return new VavrEitherArbitrary<>(leftArbitrary, rightArbitrary);
    }

    public static  VavrValidationArbitrary validation(
            final Arbitrary failureArbitrary,
            final Arbitrary innerArbitrary) {
        return new VavrValidationArbitrary<>(failureArbitrary, innerArbitrary);
    }

    public static  VavrTryArbitrary try_(
            final Arbitrary innerArbitrary,
            final Arbitrary exceptionArbitrary) {
        return new VavrTryArbitrary<>(innerArbitrary, exceptionArbitrary);
    }

    public static  VavrFutureArbitrary future(
            final Arbitrary innerArbitrary,
            final Arbitrary exceptionArbitrary) {
        return new VavrFutureArbitrary<>(innerArbitrary, exceptionArbitrary);
    }

    public static  StreamableArbitrary> iterator(final Arbitrary elementArbitrary) {
        return new VavrIteratorArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> stream(final Arbitrary elementArbitrary) {
        return new VavrStreamArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> list(final Arbitrary elementArbitrary) {
        return new VavrListArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> queue(final Arbitrary elementArbitrary) {
        return new VavrQueueArbitrary<>(elementArbitrary);
    }

    public static > StreamableArbitrary> priorityQueue(
            final Arbitrary elementArbitrary) {
        return new VavrPriorityQueueArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> priorityQueue(
            final Arbitrary elementArbitrary,
            final Comparator comparator) {
        return new VavrPriorityQueueArbitrary<>(elementArbitrary, comparator);
    }

    public static  StreamableArbitrary> array(final Arbitrary elementArbitrary) {
        return new VavrArrayArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> vector(final Arbitrary elementArbitrary) {
        return new VavrVectorArbitrary<>(elementArbitrary);
    }

    public static StreamableArbitrary charSeq(final Arbitrary elementArbitrary) {
        return new VavrCharSeqArbitrary(elementArbitrary);
    }

    public static  StreamableArbitrary> hashSet(final Arbitrary elementArbitrary) {
        return new VavrHashSetArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> linkedHashSet(final Arbitrary elementArbitrary) {
        return new VavrLinkedHashSetArbitrary<>(elementArbitrary);
    }

    public static > StreamableArbitrary> treeSet(
            final Arbitrary elementArbitrary) {
        return new VavrTreeSetArbitrary<>(elementArbitrary);
    }

    public static  StreamableArbitrary> treeSet(
            final Arbitrary elementArbitrary,
            final Comparator comparator) {
        return new VavrTreeSetArbitrary<>(elementArbitrary, comparator);
    }

//    public static > StreamableArbitrary> bitSet(
//            final Arbitrary elementArbitrary) {
//        return new VavrBitSetArbitrary<>(elementArbitrary);
//    }

    public static  StreamableArbitrary> tree(final Arbitrary elementArbitrary) {
        return new VavrTreeArbitrary<>(elementArbitrary);
    }

    public static  SizableArbitrary> hashMap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return new VavrHashMapArbitrary<>(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> linkedHashMap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return new VavrLinkedHashMapArbitrary<>(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> treeMap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return new VavrTreeMapArbitrary<>(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> treeMap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary,
            final Comparator keyComparator) {
        return new VavrTreeMapArbitrary<>(keysArbitrary, valuesArbitrary, keyComparator);
    }

    public static  SizableArbitrary> hashMultimap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return new VavrHashMultimapArbitrary<>(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> linkedHashMultimap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return new VavrLinkedHashMultimapArbitrary<>(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> treeMultimap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return new VavrTreeMultimapArbitrary<>(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> treeMultimap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary,
            final Comparator keyComparator) {
        return new VavrTreeMultimapArbitrary<>(keysArbitrary, valuesArbitrary, keyComparator);
    }

    /*
     * Interfaces
     */

    public static  StreamableArbitrary> seq(final Arbitrary elementArbitrary) {
        return list(elementArbitrary);
    }

    public static  StreamableArbitrary> linearSeq(final Arbitrary elementArbitrary) {
        return list(elementArbitrary);
    }

    public static  StreamableArbitrary> indexedSeq(final Arbitrary elementArbitrary) {
        return array(elementArbitrary);
    }

    public static  StreamableArbitrary> set(final Arbitrary elementArbitrary) {
        return hashSet(elementArbitrary);
    }

    public static > StreamableArbitrary> sortedSet(
            final Arbitrary elementArbitrary) {
        return treeSet(elementArbitrary);
    }

    public static  SizableArbitrary> map(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return hashMap(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> sortedMap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return treeMap(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> multimap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return hashMultimap(keysArbitrary, valuesArbitrary);
    }

    public static  SizableArbitrary> sortedMultimap(
            final Arbitrary keysArbitrary,
            final Arbitrary valuesArbitrary) {
        return treeMultimap(keysArbitrary, valuesArbitrary);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy