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

com.aol.cyclops.lambda.tuple.lazymap.LazyMap7PTuple8 Maven / Gradle / Ivy

There is a newer version: 7.2.4
Show newest version
package com.aol.cyclops.lambda.tuple.lazymap;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;

import com.aol.cyclops.closures.immutable.LazyImmutable;
import com.aol.cyclops.lambda.tuple.PTuple8;
import com.aol.cyclops.lambda.tuple.TupleImpl;

/**
 * Created by johnmcclean on 5/21/15.
 */
public class LazyMap7PTuple8 extends TupleImpl {
    private final LazyImmutable value = LazyImmutable.def();
    private final Function fn;
    private final PTuple8 host;
    public LazyMap7PTuple8( Function fn,PTuple8 host){
        super(host.arity());
        this.host = host;
        this.fn = fn;
    }
    public T v7(){
        return value.computeIfAbsent(()->fn.apply(host.v7()));
    }

    @Override
    public List getCachedValues() {
        return Arrays.asList(v1(), v2());
    }

    @Override
    public Iterator iterator() {
        return getCachedValues().iterator();
    }


}