org.dromara.hutool.db.sql.ConditionBuilder Maven / Gradle / Ivy
/*
* Copyright (c) 2013-2024 Hutool Team and hutool.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.hutool.db.sql;
import org.dromara.hutool.core.lang.builder.Builder;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.text.CharUtil;
import org.dromara.hutool.core.text.StrUtil;
import java.util.ArrayList;
import java.util.List;
/**
* 多条件构建封装
* 可以将多个条件构建为SQL语句的一部分,并将参数值转换为占位符,并提取对应位置的参数值。
* 例如:name = ? AND type IN (?, ?) AND other LIKE ?
*
* @author looly
* @since 5.4.3
*/
public class ConditionBuilder implements Builder {
private static final long serialVersionUID = 1L;
/**
* 创建构建器
*
* @param conditions 条件列表
* @return ConditionBuilder
*/
public static ConditionBuilder of(final Condition... conditions) {
return new ConditionBuilder(conditions);
}
/**
* 条件数组
*/
private final Condition[] conditions;
/**
* 占位符对应的值列表
*/
private List