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

group.flyfish.fluent.entity.SQLEntity Maven / Gradle / Ivy

package group.flyfish.fluent.entity;

import java.util.function.Supplier;

/**
 * sql运行实体
 *
 * @author wangyu
 */
public class SQLEntity {

    private static final Supplier EMPTY_PARAMETERS = () -> new Object[]{};

    // sql提供者
    private Supplier sqlProvider;

    // sql参数表提供者
    private Supplier parametersProvider;

    public static SQLEntity of(Supplier sqlProvider) {
        return of(sqlProvider, EMPTY_PARAMETERS);
    }

    public static SQLEntity of(Supplier sqlProvider, Supplier parametersProvider) {
        SQLEntity entity = new SQLEntity();
        entity.sqlProvider = sqlProvider;
        entity.parametersProvider = parametersProvider;
        return entity;
    }

    public String getSql() {
        return sqlProvider.get();
    }

    public Object[] getParameters() {
        return parametersProvider.get();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy