2 * This file is part of memoization.java. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of memoization.java,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
7 package de
.xn__ho_hia
.memoization
.guava
;
9 import java
.util
.function
.BiFunction
;
11 import com
.google
.common
.cache
.Cache
;
13 final class GuavaCacheBasedBiFunctionMemoizer
<FIRST
, SECOND
, KEY
, OUTPUT
>
14 extends AbstractGuavaCacheBasedMemoizer
<KEY
, OUTPUT
>
15 implements BiFunction
<FIRST
, SECOND
, OUTPUT
> {
17 private final BiFunction
<FIRST
, SECOND
, KEY
> keyFunction
;
18 private final BiFunction
<FIRST
, SECOND
, OUTPUT
> biFunction
;
20 GuavaCacheBasedBiFunctionMemoizer(
21 final Cache
<KEY
, OUTPUT
> cache
,
22 final BiFunction
<FIRST
, SECOND
, KEY
> keyFunction
,
23 final BiFunction
<FIRST
, SECOND
, OUTPUT
> biFunction
) {
25 this.keyFunction
= keyFunction
;
26 this.biFunction
= biFunction
;
30 public OUTPUT
apply(final FIRST first
, final SECOND second
) {
31 final KEY key
= keyFunction
.apply(first
, second
);
32 return get(key
, givenKey
-> biFunction
.apply(first
, second
));