diff --git a/infinitic-common/src/main/kotlin/io/infinitic/annotations/Batch.kt b/infinitic-common/src/main/kotlin/io/infinitic/annotations/Batch.kt index 0b5b4827c..c5efe9f8c 100644 --- a/infinitic-common/src/main/kotlin/io/infinitic/annotations/Batch.kt +++ b/infinitic-common/src/main/kotlin/io/infinitic/annotations/Batch.kt @@ -24,4 +24,4 @@ package io.infinitic.annotations /** Use this annotation to define a timeout duration for tasks */ @Target(AnnotationTarget.FUNCTION) -annotation class Batch(val maxMessage: Int = 100, val maxDelaySeconds: Double = 1.0) +annotation class Batch(val maxMessage: Int, val maxDelaySeconds: Double) diff --git a/infinitic-common/src/test/java/io/infinitic/common/utils/java/BatchUtilTests.java b/infinitic-common/src/test/java/io/infinitic/common/utils/java/BatchUtilTests.java index aeac5a6ed..2c65f8c92 100644 --- a/infinitic-common/src/test/java/io/infinitic/common/utils/java/BatchUtilTests.java +++ b/infinitic-common/src/test/java/io/infinitic/common/utils/java/BatchUtilTests.java @@ -1,41 +1,40 @@ -/** +/* * "Commons Clause" License Condition v1.0 - *

+ * * The Software is provided to you by the Licensor under the License, as defined below, subject to * the following condition. - *

+ * * Without limiting other conditions in the License, the grant of rights under the License will not * include, and the License does not grant to you, the right to Sell the Software. - *

+ * * For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you * under the License to provide to third parties, for a fee or other consideration (including * without limitation fees for hosting or consulting/ support services related to the Software), a * product or service whose value derives, entirely or substantially, from the functionality of the * Software. Any license notice or attribution required by the License must also include this * Commons Clause License Condition notice. - *

+ * * Software: Infinitic - *

+ * * License: MIT License (https://opensource.org/licenses/MIT) - *

+ * * Licensor: infinitic.io */ - package io.infinitic.common.utils.java; import io.infinitic.annotations.Batch; +import java.util.Arrays; import java.util.List; import java.util.Set; // 1 parameter - Batched method with Collection parameter -@SuppressWarnings("ALL") class FooBatch1 { public String bar(int p) { return Integer.toString(p); } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List p) { return p.stream().map(Object::toString).toList(); } @@ -47,9 +46,9 @@ public String bar(int p) { return Integer.toString(p); } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(int... p) { - return java.util.Arrays.stream(p).mapToObj(Integer::toString).toList(); + return Arrays.stream(p).mapToObj(Integer::toString).toList(); } } @@ -59,7 +58,7 @@ public String bar(int p, int q) { return Integer.toString(p) + q; } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List l) { return l.stream().map(pair -> bar(pair.p(), pair.q())).toList(); } @@ -71,9 +70,9 @@ public String bar(int p, int q) { return Integer.toString(p) + q; } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(PairInt... l) { - return java.util.Arrays.stream(l).map(pair -> bar(pair.p(), pair.q())).toList(); + return Arrays.stream(l).map(pair -> bar(pair.p(), pair.q())).toList(); } } @@ -83,7 +82,7 @@ public String bar(Set p) { return p.toString(); } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List> p) { return p.stream().map(Set::toString).toList(); } @@ -95,7 +94,7 @@ public void bar(int p, int q) { // do nothing } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public void bar(List p) { // do nothing } @@ -107,7 +106,7 @@ public void bar(MyPair pair) { // do nothing } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public void bar(List> pairs) { // do nothing } @@ -119,7 +118,7 @@ public String bar(int p) { return Integer.toString(p); } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List p, int q) { return p.stream().map(Object::toString).toList(); } @@ -131,7 +130,7 @@ public String bar(int p, int q) { return Integer.toString(p) + q; } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List p) { return p.stream().map(Object::toString).toList(); } @@ -143,14 +142,14 @@ public String bar(int p, int q) { return Integer.toString(p) + q; } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List p) { return p.stream().map(Object::toString).toList(); } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(PairInt... p) { - return java.util.Arrays.stream(p).map(Object::toString).toList(); + return Arrays.stream(p).map(Object::toString).toList(); } } @@ -160,7 +159,7 @@ public String bar(int p, int q) { return "?"; } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public List bar(List p) { return p.stream().map(pair -> pair.p() + pair.q()).toList(); } @@ -172,7 +171,7 @@ public String bar(int p, int q) { return "?"; } - @Batch + @Batch(maxMessage = 10, maxDelaySeconds = 1.0) public String bar(List p) { return "?"; }