All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.qute.runtime.extensions.CollectionTemplateExtensions Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.qute.runtime.extensions;

import java.util.List;

import javax.enterprise.inject.Vetoed;

import io.quarkus.qute.Results.Result;
import io.quarkus.qute.TemplateExtension;

@Vetoed // Make sure no bean is created from this class
@TemplateExtension
public class CollectionTemplateExtensions {

    static Object get(List list, int index) {
        return list.get(index);
    }

    @TemplateExtension(matchRegex = "\\d{1,10}")
    static Object getByIndex(List list, String index) {
        int idx = Integer.parseInt(index);
        if (idx >= list.size()) {
            // Be consistent with property resolvers
            return Result.NOT_FOUND;
        }
        return list.get(idx);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy