
org.jsimpledb.parse.func.ConcatFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsimpledb-parse Show documentation
Show all versions of jsimpledb-parse Show documentation
JSimpleDB classes for parsing Java expressions.
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package org.jsimpledb.parse.func;
import com.google.common.collect.Iterables;
import org.jsimpledb.SessionMode;
import org.jsimpledb.parse.ParseSession;
import org.jsimpledb.parse.expr.AbstractValue;
import org.jsimpledb.parse.expr.EvalException;
import org.jsimpledb.parse.expr.Value;
@Function(modes = { SessionMode.KEY_VALUE, SessionMode.CORE_API, SessionMode.JSIMPLEDB })
public class ConcatFunction extends SimpleFunction {
public ConcatFunction() {
super("concat", 1, 1);
}
@Override
public String getHelpSummary() {
return "Concatenates the Iterables within an Iterable";
}
@Override
public String getUsage() {
return "concat(items)";
}
@Override
public String getHelpDetail() {
return "The concat() function takes an argument which must be an Iterable of Iterables (i.e., an instance of"
+ " Iterable extends Iterable>>), and returns a new Iterable> which is the concatenation of the inner Iterables.";
}
@Override
protected Value apply(ParseSession session, Value[] params) {
final Value value = params[0];
return new AbstractValue() {
@Override
public Object get(final ParseSession session) {
return Iterables.concat(Iterables.transform((Iterable>)value.checkType(session, "concat()", Iterable.class),
new com.google.common.base.Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy