1
1
package net .quickwrite .fluent4j .functions ;
2
2
3
- import net .quickwrite .fluent4j .util . args . FluentArgs ;
3
+ import net .quickwrite .fluent4j .exception . RecursionDepthReachedException ;
4
4
import net .quickwrite .fluent4j .util .args .FunctionFluentArgs ;
5
- import net .quickwrite .fluent4j .util .bundle .DirectFluentBundle ;
6
5
import net .quickwrite .fluent4j .ast .placeable .base .FluentPlaceable ;
7
6
import net .quickwrite .fluent4j .ast .placeable .NumberLiteral ;
8
7
import net .quickwrite .fluent4j .util .bundle .args .AccessorBundle ;
@@ -50,6 +49,27 @@ public String getIdentifier() {
50
49
return this .identifier ;
51
50
}
52
51
52
+ /**
53
+ * Returns the result of {@link AbstractFunction#getResult(AccessorBundle, FunctionFluentArgs, int)},
54
+ * but also checks the recursion depth.
55
+ *
56
+ * @param bundle The bundle that this is getting called from
57
+ * @param arguments The arguments the function gets
58
+ * @param recursionDepth The amount of recursive calls that can still be made
59
+ * @return The result
60
+ */
61
+ public FluentPlaceable getFunctionResult (
62
+ final AccessorBundle bundle ,
63
+ final FunctionFluentArgs arguments ,
64
+ final int recursionDepth
65
+ ) {
66
+ if (recursionDepth <= 0 ) {
67
+ throw new RecursionDepthReachedException ();
68
+ }
69
+
70
+ return getResult (bundle , arguments , recursionDepth );
71
+ }
72
+
53
73
/**
54
74
* Returns the value that should result from the
55
75
* specific argument or the bundle itself. <br>
@@ -69,7 +89,8 @@ public String getIdentifier() {
69
89
*
70
90
* @param bundle The bundle that this is getting called from
71
91
* @param arguments The arguments the function gets
92
+ * @param recursionDepth The amount of recursive calls that can still be made
72
93
* @return The result
73
94
*/
74
- public abstract FluentPlaceable getResult (final AccessorBundle bundle , final FunctionFluentArgs arguments );
95
+ public abstract FluentPlaceable getResult (final AccessorBundle bundle , final FunctionFluentArgs arguments , final int recursionDepth );
75
96
}
0 commit comments