![JAR search and dependency download from the Maven repository](/logo.png)
org.dflib.exp.ExpScalar1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dflib Show documentation
Show all versions of dflib Show documentation
dflib: DataFrame library
package org.dflib.exp;
import org.dflib.DataFrame;
import org.dflib.Exp;
import org.dflib.Series;
import java.util.Objects;
/**
* A unary expression with a scalar argument.
*
* @since 0.11
*/
public abstract class ExpScalar1 implements Exp {
private final Class type;
protected final T value;
public ExpScalar1(T value, Class type) {
this.value = value;
this.type = Objects.requireNonNull(type);
}
@Override
public String toString() {
return toQL();
}
@Override
public Class getType() {
return type;
}
@Override
public String toQL() {
boolean quotes = value != null && !(value instanceof Number);
String unquoted = String.valueOf(value);
return quotes ? "'" + unquoted + "'" : unquoted;
}
@Override
public String toQL(DataFrame df) {
return toQL();
}
@Override
public Series eval(DataFrame df) {
return doEval(df.height());
}
@Override
public Series eval(Series> s) {
return doEval(s.size());
}
protected abstract Series doEval(int height);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy