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

com.xhinliang.jugg.plugin.preload.CollectionFunctionPreloader Maven / Gradle / Ivy

package com.xhinliang.jugg.plugin.preload;

import java.util.List;

import com.google.common.collect.ImmutableList;

/**
 * @author xhinliang 
 * Created on 2019-04-20
 */
public class CollectionFunctionPreloader implements IJuggPreloader {

    @Override
    public List getScripts() {
        return ImmutableList. builder() //
                .add("" //
                        + "def filterToList(tempCollection, tempFilterFun) {\n" //
                        + "    tempResult = [];\n" //
                        + "    foreach (item : tempCollection) {\n" //
                        + "        if (tempFilterFun(item)) {\n" //
                        + "            tempResult.add(item);\n" //
                        + "        }\n" //
                        + "    }\n" //
                        + "    return tempResult;\n" //
                        + "}\n")
                .build();
    }

    @Override
    public String packageName() {
        return "collectionFunction";
    }

    @Override
    public String desc() {
        return "functions for collection.";
    }

    @Override
    public String sampleInput() {
        return "filterToList([4L, 23, 22, 21], def (number) { number > 10 })";
    }

    @Override
    public Object sampleOutput() {
        // CHECKSTYLE:OFF
        return ImmutableList.of(23, 22, 21);
        // CHECKSTYLE:ON
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy