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

com.enonic.xp.query.expr.FunctionExpr Maven / Gradle / Ivy

There is a newer version: 7.14.4
Show newest version
package com.enonic.xp.query.expr;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableList;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public final class FunctionExpr
    implements Expression
{
    private final String name;

    private final ImmutableList arguments;

    public FunctionExpr( final String name, final Iterable arguments )
    {
        this.name = name;
        this.arguments = ImmutableList.copyOf( arguments );
    }

    public static FunctionExpr from( final String functionName, final Iterable arguments )
    {
        return new FunctionExpr( functionName, arguments );
    }

    public static FunctionExpr from( final String functionName, ValueExpr... arguments )
    {
        return new FunctionExpr( functionName, Arrays.asList( arguments ) );
    }

    public String getName()
    {
        return this.name;
    }

    public List getArguments()
    {
        return this.arguments;
    }

    @Override
    public String toString()
    {
        return this.name + this.arguments.stream().map( Objects::toString ).collect( Collectors.joining( ", ", "(", ")" ) );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy