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

net.intelie.pipes.ValueFunction Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes;

import net.intelie.pipes.types.Type;
import net.intelie.pipes.util.LiteralRepresentation;

public class ValueFunction implements Function {
    private static final long serialVersionUID = 1L;

    private final String name;
    private final Type type;
    private final Object value;

    public ValueFunction(String name, Object value) {
        this(name, Type.infer(value), value);
    }

    public ValueFunction(String name, Type type, Object value) {
        this.name = name;
        this.type = type;
        this.value = value;
    }

    @Override
    public Object declare(ArgQueue queue) throws PipeException {
        return new Literal<>(type, value);
    }

    @Override
    public String description() {
        return "value " + LiteralRepresentation.toString(type, value);
    }

    @Override
    public String name() {
        return name;
    }

    @Override
    public HelpData help() {
        return new HelpData(
                null,
                name,
                name + (!name.startsWith("@") ? "()" : ""),
                "value " + LiteralRepresentation.toString(type, value),
                null,
                null,
                null,
                null
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy