package bjc.utils.data.lazy; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Function; import bjc.utils.data.IPair; /** * A lazy holder of two values * * Lazy variant of {@link IPair} * * @author ben * * @param * The type of value stored on the left side of the pair * @param * The type of value stored on the right side of the pair */ public class LazyPair implements IPair { /** * The backing store for this pair */ protected LazyHolder> del; /* * (non-Javadoc) * * @see bjc.utils.data.IPair#apply(java.util.function.Function, * java.util.function.Function) */ @Override public IPair apply(Function lf, Function rf) { return del.unwrap((par) -> par.apply(lf, rf)); } /* * (non-Javadoc) * * @see bjc.utils.data.IPair#doWith(java.util.function.BiConsumer) */ @Override public void doWith(BiConsumer bc) { del.doWith((par) -> { par.doWith(bc); }); } /* * (non-Javadoc) * * @see bjc.utils.data.IPair#merge(java.util.function.BiFunction) */ @Override public E merge(BiFunction bf) { return del.unwrap((par) -> par.merge(bf)); } }