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

net.intelie.pipes.RawFunction 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 RawFunction implements Function {
    private static final long serialVersionUID = 1L;

    private final String name;
    private final Object value;
    private final HelpData help;

    public RawFunction(String name, Object value) {
        this(name, value,
                new HelpData(null, name, name + (!name.startsWith("@") ? "()" : ""), makeDescription(value), null, null, null, null));
    }

    private static String makeDescription(Object value) {
        return "raw " + LiteralRepresentation.toString(Type.infer(value), value);
    }

    public RawFunction(String name, Object value, HelpData help) {
        this.name = name;
        this.value = value;
        this.help = help;
    }

    @Override
    public Object declare(ArgQueue queue) throws PipeException {
        return value;
    }

    @Override
    public String description() {
        return makeDescription(value);
    }

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

    @Override
    public HelpData help() {
        return help;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy