28 |
import org.nongnu.libvob.gl.PaperMill; |
import org.nongnu.libvob.gl.PaperMill; |
29 |
import org.nongnu.libvob.gl.SpecialPapers; |
import org.nongnu.libvob.gl.SpecialPapers; |
30 |
import org.fenfire.functional.Function; |
import org.fenfire.functional.Function; |
31 |
|
import org.fenfire.functional.PureFunction; |
32 |
import org.fenfire.functional.Functional; |
import org.fenfire.functional.Functional; |
33 |
|
|
34 |
/** Adapt a PaperMill into the Function API. |
/** Adapt a PaperMill into the Function API. |
35 |
* Input: any object. Output an org.nongnu.libvob.gl.Paper object |
* Input: any object. Output an org.nongnu.libvob.gl.Paper object |
36 |
* based on the hashcode of the object. |
* based on the hashcode of the object. |
37 |
*/ |
*/ |
38 |
public class PaperMillFunction implements Function { |
public class PaperMillFunction implements PureFunction { |
39 |
private boolean useOptimized; |
/** Whether we should request optimized papers from the papermill. |
40 |
private PaperMill paperMill; |
*/ |
41 |
|
private final boolean useOptimized; |
42 |
|
/** The offset to add to the hashcode. |
43 |
|
*/ |
44 |
|
private final int offset; |
45 |
|
|
46 |
|
/** The papermill to use. |
47 |
|
*/ |
48 |
|
private final PaperMill paperMill; |
49 |
|
|
50 |
static public Functional.Hints functionalHints = |
static public Functional.Hints functionalHints = |
51 |
(new Functional.HintsMaker()) |
(new Functional.HintsMaker()) |
53 |
.setHint(Functional.HINT_PLACEHOLDER, null) |
.setHint(Functional.HINT_PLACEHOLDER, null) |
54 |
.make(); |
.make(); |
55 |
|
|
56 |
|
/** Create a new PaperMillFunction. |
57 |
|
* @param paperMill The papermill to use |
58 |
|
* @param useOptimized Whether to return optimized or non-optimized |
59 |
|
* papers from the papermill |
60 |
|
*/ |
61 |
public PaperMillFunction(PaperMill paperMill, boolean useOptimized) { |
public PaperMillFunction(PaperMill paperMill, boolean useOptimized) { |
62 |
|
this(paperMill, useOptimized, 0); |
63 |
|
} |
64 |
|
|
65 |
|
/** Create a new PaperMillFunction. |
66 |
|
* @param paperMill The papermill to use |
67 |
|
* @param useOptimized Whether to return optimized or non-optimized |
68 |
|
* papers from the papermill |
69 |
|
* @param offset The offset to add to the hashCode before calling |
70 |
|
* getPaper or getOptimizedPaper. |
71 |
|
*/ |
72 |
|
public PaperMillFunction(PaperMill paperMill, boolean useOptimized, |
73 |
|
int offset) { |
74 |
this.paperMill = paperMill; |
this.paperMill = paperMill; |
75 |
this.useOptimized = useOptimized; |
this.useOptimized = useOptimized; |
76 |
|
this.offset = offset; |
77 |
} |
} |
78 |
|
|
79 |
public Object f(Object input) { |
public Object f(Object input) { |