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

tk.mybatis.mapper.weekend.WeekendSqlsUtils Maven / Gradle / Ivy

The newest version!
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2017 the original author or authors.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

package tk.mybatis.mapper.weekend;

import tk.mybatis.mapper.weekend.reflection.Reflections;

/**
 * {@link WeekendSqls} 的工具类,提供一系列静态方法,减少泛型参数的指定,使代码更简洁、清晰
 *
 * 直接使用WeekSqls,以下的查询需要指定两次Country类:
 *  List selectByWeekendSql = mapper.selectByExample(new Example.Builder(Country.class)
 *         .where(WeekendSqls.custom().andLike(Country::getCountryname, "%a%")
 *                 .andGreaterThan(Country::getCountrycode, "123"))
 *         .build());
 *
 * 使用 WeekendSqlsUtils,只需指定一次Country类:
 *  List selectByWeekendSql = mapper.selectByExample(new Example.Builder(Country.class)
 *                     .where(WeekendSqlsUtils.andLike(Country::getCountryname, "%a%")
 *                             .andGreaterThan(Country::getCountrycode, "123"))
 *                     .build());
 *
 *  建议使用 import static,代码会简洁一些
 *  import static tk.mybatis.mapper.weekend.WeekendSqlsUtils.andLike;
 *
 *  List selectByWeekendSql = mapper.selectByExample(new Example.Builder(Country.class)
 *                     .where(andLike(Country::getCountryname, "%a%")
 *                             .andGreaterThan(Country::getCountrycode, "123"))
 *                     .build());
 * @author linweichao
 * @date 2019/5/20
 */
public class WeekendSqlsUtils {

    public static  WeekendSqls andIsNull(String property) {
        return WeekendSqls.custom().andIsNull(property);
    }

    public static  WeekendSqls andIsNull(Fn fn) {
        return WeekendSqls.custom().andIsNull(fn);
    }

    public static  WeekendSqls andIsNotNull(String property) {
        return WeekendSqls.custom().andIsNotNull(property);
    }

    public static  WeekendSqls andIsNotNull(Fn fn) {
        return WeekendSqls.custom().andIsNotNull(fn);
    }

    public static  WeekendSqls andEqualTo(String property, Object value) {
        return WeekendSqls.custom().andEqualTo(property, value);
    }

    public static  WeekendSqls andEqualTo(Fn fn, Object value) {
        return WeekendSqls.custom().andEqualTo(fn, value);
    }

    public static  WeekendSqls andNotEqualTo(String property, Object value) {
        return WeekendSqls.custom().andNotEqualTo(property, value);
    }

    public static  WeekendSqls andNotEqualTo(Fn fn, Object value) {
        return WeekendSqls.custom().andNotEqualTo(fn, value);
    }

    public static  WeekendSqls andGreaterThan(String property, Object value) {
        return WeekendSqls.custom().andGreaterThan(property, value);
    }

    public static  WeekendSqls andGreaterThan(Fn fn, Object value) {
        return WeekendSqls.custom().andGreaterThan(fn, value);
    }

    public static  WeekendSqls andGreaterThanOrEqualTo(String property, Object value) {
        return WeekendSqls.custom().andGreaterThanOrEqualTo(property, value);
    }

    public static  WeekendSqls andGreaterThanOrEqualTo(Fn fn, Object value) {
        return WeekendSqls.custom().andGreaterThanOrEqualTo(fn, value);
    }

    public static  WeekendSqls andLessThan(String property, Object value) {
        return WeekendSqls.custom().andLessThan(property, value);
    }

    public static  WeekendSqls andLessThan(Fn fn, Object value) {
        return WeekendSqls.custom().andLessThan(fn, value);
    }

    public static  WeekendSqls andLessThanOrEqualTo(String property, Object value) {
        return WeekendSqls.custom().andLessThanOrEqualTo(property, value);
    }

    public static  WeekendSqls andLessThanOrEqualTo(Fn fn, Object value) {
        return WeekendSqls.custom().andLessThanOrEqualTo(fn, value);
    }

    public static  WeekendSqls andIn(String property, Iterable values) {
        return WeekendSqls.custom().andIn(property, values);
    }

    public static  WeekendSqls andIn(Fn fn, Iterable values) {
        return WeekendSqls.custom().andIn(fn, values);
    }

    public static  WeekendSqls andNotIn(String property, Iterable values) {
        return WeekendSqls.custom().andNotIn(property, values);
    }

    public static  WeekendSqls andNotIn(Fn fn, Iterable values) {
        return WeekendSqls.custom().andNotIn(fn, values);
    }

    public static  WeekendSqls andBetween(String property, Object value1, Object value2) {
        return WeekendSqls.custom().andBetween(property, value1, value2);
    }

    public static  WeekendSqls andBetween(Fn fn, Object value1, Object value2) {
        return WeekendSqls.custom().andBetween(fn, value1, value2);
    }

    public static  WeekendSqls andNotBetween(String property, Object value1, Object value2) {
        return WeekendSqls.custom().andNotBetween(property, value1, value2);
    }

    public static  WeekendSqls andNotBetween(Fn fn, Object value1, Object value2) {
        return WeekendSqls.custom().andNotBetween(fn, value1, value2);
    }

    public static  WeekendSqls andLike(String property, String value) {
        return WeekendSqls.custom().andLike(property, value);
    }

    public static  WeekendSqls andLike(Fn fn, String value) {
        return WeekendSqls.custom().andLike(fn, value);
    }

    public static  WeekendSqls andNotLike(String property, String value) {
        return WeekendSqls.custom().andNotLike(property, value);
    }

    public static  WeekendSqls andNotLike(Fn fn, String value) {
        return WeekendSqls.custom().andNotLike(fn ,value);
    }

    public static  WeekendSqls orIsNull(String property) {
        return WeekendSqls.custom().orIsNull(property);
    }

    public static  WeekendSqls orIsNull(Fn fn) {
        return WeekendSqls.custom().orIsNull(fn);
    }

    public static  WeekendSqls orIsNotNull(String property) {
        return WeekendSqls.custom().orIsNotNull(property);
    }

    public static  WeekendSqls orIsNotNull(Fn fn) {
        return WeekendSqls.custom().orIsNotNull(fn);
    }

    public static  WeekendSqls orEqualTo(String property, Object value) {
        return WeekendSqls.custom().orEqualTo(property, value);
    }

    public static  WeekendSqls orEqualTo(Fn fn, String value) {
        return WeekendSqls.custom().orEqualTo(fn, value);
    }

    public static  WeekendSqls orNotEqualTo(String property, Object value) {
        return WeekendSqls.custom().orNotEqualTo(property, value);
    }

    public static  WeekendSqls orNotEqualTo(Fn fn, String value) {
        return WeekendSqls.custom().orNotEqualTo(fn, value);
    }

    public static  WeekendSqls orGreaterThan(String property, Object value) {
        return WeekendSqls.custom().orGreaterThan(property, value);
    }

    public static  WeekendSqls orGreaterThan(Fn fn, String value) {
        return WeekendSqls.custom().orGreaterThan(fn, value);
    }

    public static  WeekendSqls orGreaterThanOrEqualTo(String property, Object value) {
        return WeekendSqls.custom().orGreaterThanOrEqualTo(property, value);
    }

    public static  WeekendSqls orGreaterThanOrEqualTo(Fn fn, String value) {
        return WeekendSqls.custom().orGreaterThanOrEqualTo(fn, value);
    }

    public static  WeekendSqls orLessThan(String property, Object value) {
        return WeekendSqls.custom().orLessThan(property, value);
    }

    public static  WeekendSqls orLessThan(Fn fn, String value) {
        return WeekendSqls.custom().orLessThan(fn, value);
    }

    public static  WeekendSqls orLessThanOrEqualTo(String property, Object value) {
        return WeekendSqls.custom().orLessThanOrEqualTo(property, value);
    }

    public static  WeekendSqls orLessThanOrEqualTo(Fn fn, String value) {
        return WeekendSqls.custom().orLessThanOrEqualTo(fn, value);
    }

    public static  WeekendSqls orIn(String property, Iterable values) {
        return WeekendSqls.custom().orIn(property, values);
    }

    public static  WeekendSqls orIn(Fn fn, Iterable values) {
        return WeekendSqls.custom().orIn(fn, values);
    }

    public static  WeekendSqls orNotIn(String property, Iterable values) {
        return WeekendSqls.custom().orNotIn(property, values);
    }

    public static  WeekendSqls orNotIn(Fn fn, Iterable values) {
        return WeekendSqls.custom().orNotIn(fn, values);
    }

    public static  WeekendSqls orBetween(String property, Object value1, Object value2) {
        return WeekendSqls.custom().orBetween(property, value1, value2);
    }

    public static  WeekendSqls orBetween(Fn fn, Object value1, Object value2) {
        return WeekendSqls.custom().orBetween(fn, value1, value2);
    }

    public static  WeekendSqls orNotBetween(String property, Object value1, Object value2) {
        return WeekendSqls.custom().orNotBetween(property, value1, value2);
    }

    public static  WeekendSqls orNotBetween(Fn fn, Object value1, Object value2) {
        return WeekendSqls.custom().orNotBetween(fn, value1, value2);
    }

    public static  WeekendSqls orLike(String property, String value) {
        return WeekendSqls.custom().orLike(property, value);
    }

    public static  WeekendSqls orLike(Fn fn, String value) {
        return WeekendSqls.custom().orLike(fn, value);
    }

    public static  WeekendSqls orNotLike(String property, String value) {
        return WeekendSqls.custom().orNotLike(property, value);
    }

    public static  WeekendSqls orNotLike(Fn fn, String value) {
        return WeekendSqls.custom().orNotLike(fn, value);
    }

    public static  String[] select(Fn... fn) {
        return Reflections.fnToFieldNames(fn);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy