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

jaskell.sql.Exists Maven / Gradle / Ivy

Go to download

This is a utils library for java 8 project. It include parsec combinators and sql generators library.

There is a newer version: 2.9.2
Show newest version
package jaskell.sql;

import jaskell.script.Directive;
import jaskell.script.Parameter;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Exists extends Predicate {
    Optional _prefix;
    Directive directive;

    Exists(Directive directive){
        _prefix = Optional.empty();
        this.directive = directive;
    }

    @Override
    public String script() {
        if(_prefix.isPresent()) {
            return String.format("%s EXISTS(%s)", _prefix.get().script(), directive.script());
        }else {
            return String.format("EXISTS(%s)", directive.script());
        }
    }

    @Override
    public List> parameters() {
        if (_prefix.isPresent()){
            return Stream.concat(_prefix.get().parameters().stream(), directive.parameters().stream())
                    .collect(Collectors.toList());
        }else {
            return directive.parameters();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy