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

cyclops.monads.VavrWitness Maven / Gradle / Ivy

The newest version!
package cyclops.monads;



import com.aol.cyclops.vavr.adapter.*;
import com.aol.cyclops2.types.extensability.FunctionalAdapter;

import io.vavr.collection.*;
import io.vavr.concurrent.Future;
import io.vavr.control.Either;
import io.vavr.control.Option;
import io.vavr.control.Try;

public interface VavrWitness {

    public static  List list(AnyM anyM){
        return anyM.unwrap();
    }
    public static  Vector vector(AnyM anyM){
        return anyM.unwrap();
    }
    public static  Queue queue(AnyM anyM){
        return anyM.unwrap();
    }
    public static  Option option(AnyM anyM){
        return anyM.unwrap();
    }
    public static  Try tryType(AnyM anyM){
        return anyM.unwrap();
    }
    public static  Future future(AnyM anyM){
        return anyM.unwrap();
    }
    public static  Either either(AnyM anyM){
        return anyM.unwrap();
    }

    static interface TraversableWitness>  extends WitnessType{

    }
    public static enum stream implements TraversableWitness {
        INSTANCE;

        @Override
        public FunctionalAdapter adapter() {
            return new TraversableAdapter(INSTANCE){

                @Override
                public Traversable traversableFromIterable(Iterable value) {
                    return Stream.ofAll(value);
                }

                @Override
                public Traversable singletonTraversable(Object value) {
                    return Stream.of(value);
                }

                @Override
                public Traversable emptyTraversable() {
                    return Stream.empty();
                }
            };
        }

    }
    public static enum list implements TraversableWitness {
        INSTANCE;

        @Override
        public FunctionalAdapter adapter() {
            return new TraversableAdapter(INSTANCE){

                @Override
                public Traversable traversableFromIterable(Iterable value) {
                    return List.ofAll(value);
                }

                @Override
                public Traversable singletonTraversable(Object value) {
                    return List.of(value);
                }

                @Override
                public Traversable emptyTraversable() {
                    return List.empty();
                }
            };
        }

    }
    public static enum vector implements TraversableWitness {
        INSTANCE;

        @Override
        public FunctionalAdapter adapter() {
            return new TraversableAdapter(INSTANCE){

                @Override
                public Traversable traversableFromIterable(Iterable value) {
                    return Vector.ofAll(value);
                }

                @Override
                public Traversable singletonTraversable(Object value) {
                    return Vector.of(value);
                }

                @Override
                public Traversable emptyTraversable() {
                    return Vector.empty();
                }
            };
        }

    }
    public static enum array implements TraversableWitness {
        INSTANCE;

        @Override
        public FunctionalAdapter adapter() {
            return new TraversableAdapter(INSTANCE){

                @Override
                public Traversable traversableFromIterable(Iterable value) {
                    return Array.ofAll(value);
                }

                @Override
                public Traversable singletonTraversable(Object value) {
                    return Array.of(value);
                }

                @Override
                public Traversable emptyTraversable() {
                    return Array.empty();
                }
            };
        }

    }
    public static enum charSeq implements TraversableWitness {
        INSTANCE;

        @Override
        public FunctionalAdapter adapter() {
            return new TraversableAdapter(INSTANCE){

                @Override
                public Traversable traversableFromIterable(Iterable value) {
                    return CharSeq.ofAll(value);
                }

                @Override
                public Traversable singletonTraversable(Object value) {
                    return CharSeq.of((Character)value);
                }

                @Override
                public Traversable emptyTraversable() {
                    return CharSeq.empty();
                }
            };
        }

    }
    public static enum queue implements TraversableWitness {
        INSTANCE;

        @Override
        public FunctionalAdapter adapter() {
            return new TraversableAdapter(INSTANCE){

                @Override
                public Traversable traversableFromIterable(Iterable value) {
                    return Queue.ofAll(value);
                }

                @Override
                public Traversable singletonTraversable(Object value) {
                    return Queue.of(value);
                }

                @Override
                public Traversable emptyTraversable() {
                    return Queue.empty();
                }
            };
        }

    }

    static interface OptionWitness>  extends WitnessType {

    }
    public static enum option implements OptionWitness




© 2015 - 2024 Weber Informatics LLC | Privacy Policy