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

hydra.lib.strings.IsEmpty Maven / Gradle / Ivy

package hydra.lib.strings;

import hydra.compute.Flow;
import hydra.core.Name;
import hydra.core.Term;
import hydra.core.Type;
import hydra.dsl.Expect;
import hydra.dsl.Terms;
import hydra.graph.Graph;
import hydra.tools.PrimitiveFunction;

import java.util.List;
import java.util.function.Function;

import static hydra.Flows.map;
import static hydra.dsl.Types.boolean_;
import static hydra.dsl.Types.function;
import static hydra.dsl.Types.string;


public class IsEmpty extends PrimitiveFunction {
    public Name name() {
        return new Name("hydra/lib/strings.isEmpty");
    }

    @Override
    public Type type() {
        return function(string(), boolean_());
    }

    @Override
    protected Function>, Flow, Term>> implementation() {
        return args -> map(Expect.string(args.get(0)), s -> Terms.boolean_(apply(s)));
    }

    public static boolean apply(String s) {
        return s.isEmpty();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy