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

com.aol.cyclops.lambda.tuple.lazymap.LazyMap5PTuple8 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 LazyMap5PTuple8 extends TupleImpl {
    private final LazyImmutable value = LazyImmutable.def();
    private final Function fn;
    private final PTuple8 host;
    public LazyMap5PTuple8( Function fn,PTuple8 host){
        super(host.arity());
        this.host = host;
        this.fn = fn;
    }
    public T v5(){
        return value.computeIfAbsent(()->fn.apply(host.v5()));
    }

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

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


}