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

foundation.jpa.querydsl.QueryVariables Maven / Gradle / Ivy

There is a newer version: 0.29
Show newest version
package foundation.jpa.querydsl;

import java.util.Map;

public interface QueryVariables {

    Object get(String name);

    boolean isDefined(String name);

    static QueryVariables none() {
        return new QueryVariables() {
            @Override
            public Object get(String name) {
                return null;
            }

            @Override
            public boolean isDefined(String name) {
                return false;
            }
        };
    }

    static QueryVariables map(Map values) {
        return new QueryVariables() {
            @Override
            public Object get(String name) {
                return values.get(name);
            }

            @Override
            public boolean isDefined(String name) {
                return values.containsKey(name);
            }
        };
    }

    static QueryVariables local(Map values, QueryVariables parent) {
        return new QueryVariables() {
            @Override
            public Object get(String name) {
                return values.containsKey(name) ? values.get(name) : parent.get(name);
            }

            @Override
            public boolean isDefined(String name) {
                return values.containsKey(name) || parent.isDefined(name);
            }
        };
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy