diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java index a25d8b4b119322..43d7abe8261910 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java @@ -15,6 +15,7 @@ import java.util.Set; import java.util.concurrent.CompletionStage; import java.util.stream.IntStream; +import java.util.stream.LongStream; import java.util.stream.Stream; import io.quarkus.qute.SectionHelperFactory.SectionInitContext; @@ -84,6 +85,8 @@ private static int extractSize(Object it) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); + } else if (it instanceof Long) { + return (((Long) it).intValue()); } else if (it instanceof Collection) { return ((Collection) it).size(); } else if (it instanceof Map) { @@ -101,6 +104,8 @@ private Iterator extractIterator(Object it) { return ((AbstractMap) it).entrySet().iterator(); } else if (it instanceof Integer) { return IntStream.rangeClosed(1, (Integer) it).iterator(); + } else if (it instanceof Long) { + return LongStream.rangeClosed(1, (Long) it).iterator(); } else if (it.getClass().isArray()) { int length = Array.getLength(it); List elements = new ArrayList<>(length); diff --git a/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java b/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java index e5046d20de3276..5e0ccfbbdf8a2a 100644 --- a/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java +++ b/independent-projects/qute/core/src/test/java/io/quarkus/qute/LoopSectionTest.java @@ -111,6 +111,14 @@ public void testIntegerStream() { engine.parse("{#for i in total}{i}:{/for}").data("total", 3).render()); } + @Test + public void testLongStream() { + Engine engine = Engine.builder().addDefaults().build(); + + assertEquals("1:2:3:", + engine.parse("{#for i in total}{i}:{/for}").data("total", 3L).render()); + } + @Test public void testIterator() { Engine engine = Engine.builder().addDefaults().build();