Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.easy.query.api4j.select.abstraction.AbstractQueryable Maven / Gradle / Ivy
package com.easy.query.api4j.select.abstraction;
import com.easy.query.api4j.select.Queryable;
import com.easy.query.api4j.select.Queryable2;
import com.easy.query.api4j.select.impl.EasyQueryable;
import com.easy.query.api4j.select.impl.EasyQueryable2;
import com.easy.query.api4j.sql.SQLColumnAsSelector;
import com.easy.query.api4j.sql.SQLColumnSelector;
import com.easy.query.api4j.sql.SQLGroupBySelector;
import com.easy.query.api4j.sql.SQLOrderBySelector;
import com.easy.query.api4j.sql.SQLWhereAggregatePredicate;
import com.easy.query.api4j.sql.SQLWherePredicate;
import com.easy.query.api4j.sql.impl.SQLColumnAsSelectorImpl;
import com.easy.query.api4j.sql.impl.SQLColumnSelectorImpl;
import com.easy.query.api4j.sql.impl.SQLGroupBySelectorImpl;
import com.easy.query.api4j.sql.impl.SQLOrderByColumnSelectorImpl;
import com.easy.query.api4j.sql.impl.SQLWhereAggregatePredicateImpl;
import com.easy.query.api4j.sql.impl.SQLWherePredicateImpl;
import com.easy.query.core.annotation.NotNull;
import com.easy.query.core.api.dynamic.sort.ObjectSort;
import com.easy.query.core.api.pagination.EasyPageResult;
import com.easy.query.core.basic.api.select.ClientQueryable;
import com.easy.query.core.basic.api.select.ClientQueryable2;
import com.easy.query.core.basic.api.select.executor.MethodQuery;
import com.easy.query.core.basic.jdbc.executor.internal.enumerable.JdbcStreamResult;
import com.easy.query.core.basic.jdbc.parameter.ToSQLContext;
import com.easy.query.core.enums.sharding.ConnectionModeEnum;
import com.easy.query.core.expression.builder.core.ValueFilter;
import com.easy.query.core.expression.lambda.SQLConsumer;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression2;
import com.easy.query.core.expression.segment.ColumnSegment;
import com.easy.query.core.expression.sql.builder.EntityQueryExpressionBuilder;
import com.easy.query.core.expression.sql.builder.internal.ContextConfigurer;
import com.easy.query.core.metadata.EntityMetadata;
import com.easy.query.core.util.EasyCollectionUtil;
import java.sql.Statement;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
/**
* @author xuejiaming
* @FileName: AbstractSelect0.java
* @Description: 文件说明
* @Date: 2023/2/6 23:44
*/
public abstract class AbstractQueryable implements Queryable {
protected final ClientQueryable entityQueryable;
@Override
public Class queryClass() {
return entityQueryable.queryClass();
}
@Override
public EntityMetadata queryEntityMetadata() {
return entityQueryable.queryEntityMetadata();
}
public AbstractQueryable(ClientQueryable entityQueryable) {
this.entityQueryable = entityQueryable;
}
@Override
public ClientQueryable getClientQueryable() {
return entityQueryable;
}
@Override
public Queryable getQueryable() {
return this;
}
@Override
public long count() {
return entityQueryable.count();
}
@Override
public long countDistinct(SQLExpression1> selectExpression) {
return entityQueryable.countDistinct(columnSelector -> {
selectExpression.apply(new SQLColumnSelectorImpl<>(columnSelector));
});
}
@Override
public boolean any() {
return entityQueryable.any();
}
@Override
public Queryable selectCount() {
return this.selectCount(Long.class);
}
@Override
public Queryable selectCount(Class numberClass) {
ClientQueryable tNumberClientQueryable = getClientQueryable().selectCount(numberClass);
return new EasyQueryable<>(tNumberClientQueryable);
}
@Override
public TR firstOrNull(Class resultClass) {
return entityQueryable.firstOrNull(resultClass);
}
@NotNull
@Override
public TR firstNotNull(Class resultClass, String msg, String code) {
return entityQueryable.firstNotNull(resultClass, msg, code);
}
@Override
public TR singleOrNull(Class resultClass) {
return entityQueryable.singleOrNull(resultClass);
}
@Override
public T1 findOrNull(Object id) {
return entityQueryable.findOrNull(id);
}
@NotNull
@Override
public TR singleNotNull(Class resultClass, String msg, String code) {
return entityQueryable.singleNotNull(resultClass, msg, code);
}
@NotNull
@Override
public TR firstNotNull(Class resultClass, Supplier throwFunc) {
return entityQueryable.firstNotNull(resultClass,throwFunc);
}
@NotNull
@Override
public TR singleNotNull(Class resultClass, Supplier throwFunc) {
return entityQueryable.singleNotNull(resultClass,throwFunc);
}
@NotNull
@Override
public T1 findNotNull(Object id, Supplier throwFunc) {
return entityQueryable.findNotNull(id,throwFunc);
}
@Override
public Map toMap() {
return entityQueryable.toMap();
}
@Override
public List> toMaps() {
return entityQueryable.toMaps();
}
@Override
public List toList(Class resultClass) {
return entityQueryable.toList(resultClass);
}
@Override
public List toList(Class resultClass, EntityMetadata resultEntityMetadata) {
return entityQueryable.toList(resultClass,resultEntityMetadata);
}
@Override
public List toTreeList(boolean ignore) {
return entityQueryable.toTreeList(ignore);
}
@Override
public JdbcStreamResult toStreamResult(Class resultClass, SQLConsumer configurer) {
return entityQueryable.toStreamResult(resultClass,configurer);
}
@Override
public void toChunk(int size, Predicate> chunk) {
entityQueryable.toChunk(size,chunk);
}
@Override
public TR streamBy(Function, TR> fetcher, SQLConsumer configurer) {
return entityQueryable.streamBy(fetcher,configurer);
}
@Override
public String toSQL(Class resultClass, ToSQLContext toSQLContext) {
return entityQueryable.toSQL(resultClass, toSQLContext);
}
/**
* 只有select操作运行操作当前projects
*
* @param selectExpression
* @return
*/
@Override
public Queryable select(SQLExpression1> selectExpression) {
ClientQueryable select = entityQueryable.select(columnSelector -> {
selectExpression.apply(new SQLColumnSelectorImpl<>(columnSelector));
});
return new EasyQueryable<>(select);
}
@Override
public Queryable select(Class resultClass, SQLExpression1> selectExpression) {
ClientQueryable select = entityQueryable.select(resultClass, columnAsSelector -> {
selectExpression.apply(new SQLColumnAsSelectorImpl<>(columnAsSelector));
});
return new EasyQueryable<>(select);
}
@Override
public Queryable select(String columns) {
entityQueryable.select(columns);
return this;
}
@Override
public Queryable select(Collection columnSegments, boolean clearAll) {
entityQueryable.select(columnSegments, clearAll);
return this;
}
@Override
public Queryable select(Class resultClass) {
ClientQueryable select = entityQueryable.select(resultClass);
return new EasyQueryable<>(select);
}
@Override
public Queryable where(boolean condition, SQLExpression1> whereExpression) {
if (condition) {
entityQueryable.where(wherePredicate -> {
whereExpression.apply(new SQLWherePredicateImpl<>(wherePredicate));
});
}
return this;
}
@Override
public Queryable whereById(boolean condition, Object id) {
if (condition) {
entityQueryable.whereById(id);
}
return this;
}
@Override
public Queryable whereByIds(boolean condition, Collection ids) {
if (condition) {
entityQueryable.whereByIds(ids);
}
return this;
}
@Override
public Queryable whereObject(boolean condition, Object object) {
if (condition) {
entityQueryable.whereObject(object);
}
return this;
}
@Override
public Queryable groupBy(boolean condition, SQLExpression1> selectExpression) {
if (condition) {
entityQueryable.groupBy(groupBySelector -> {
selectExpression.apply(new SQLGroupBySelectorImpl<>(groupBySelector));
});
}
return this;
}
@Override
public Queryable having(boolean condition, SQLExpression1> predicateExpression) {
if (condition) {
entityQueryable.having(whereAggregatePredicate -> {
predicateExpression.apply(new SQLWhereAggregatePredicateImpl<>(whereAggregatePredicate));
});
}
return this;
}
@Override
public Queryable orderBy(boolean condition, SQLExpression1> selectExpression, boolean asc) {
if (condition) {
entityQueryable.orderBy(columnSelector -> {
selectExpression.apply(new SQLOrderByColumnSelectorImpl<>(columnSelector));
}, asc);
}
return this;
}
@Override
public Queryable orderByObject(boolean condition, ObjectSort objectSort) {
if (condition) {
entityQueryable.orderByObject(objectSort);
}
return this;
}
@Override
public Queryable limit(boolean condition, long offset, long rows) {
if (condition) {
entityQueryable.limit(offset, rows);
}
return this;
}
@Override
public Queryable distinct(boolean condition) {
if (condition) {
entityQueryable.distinct();
}
return this;
}
@Override
public EasyPageResult toPageResult(Class tResultClass, long pageIndex, long pageSize, long pageTotal) {
return entityQueryable.toPageResult(tResultClass,pageIndex, pageSize, pageTotal);
}
@Override
public EasyPageResult toShardingPageResult(Class tResultClass, long pageIndex, long pageSize, List totalLines) {
return entityQueryable.toShardingPageResult(tResultClass,pageIndex, pageSize, totalLines);
}
@Override
public EntityQueryExpressionBuilder getSQLEntityExpressionBuilder() {
return entityQueryable.getSQLEntityExpressionBuilder();
}
@Override
public Queryable2 leftJoin(Class joinClass, SQLExpression2, SQLWherePredicate> on) {
ClientQueryable2 entityQueryable2 = entityQueryable.leftJoin(joinClass, (wherePredicate1, wherePredicate2) -> {
on.apply(new SQLWherePredicateImpl<>(wherePredicate1), new SQLWherePredicateImpl<>(wherePredicate2));
});
return new EasyQueryable2<>(entityQueryable2);
}
@Override
public Queryable2 leftJoin(Queryable joinQueryable, SQLExpression2, SQLWherePredicate> on) {
ClientQueryable2 entityQueryable2 = entityQueryable.leftJoin(joinQueryable.getClientQueryable(), (wherePredicate1, wherePredicate2) -> {
on.apply(new SQLWherePredicateImpl<>(wherePredicate1), new SQLWherePredicateImpl<>(wherePredicate2));
});
return new EasyQueryable2<>(entityQueryable2);
}
@Override
public Queryable2 rightJoin(Class joinClass, SQLExpression2, SQLWherePredicate> on) {
ClientQueryable2 entityQueryable2 = entityQueryable.rightJoin(joinClass, (wherePredicate1, wherePredicate2) -> {
on.apply(new SQLWherePredicateImpl<>(wherePredicate1), new SQLWherePredicateImpl<>(wherePredicate2));
});
return new EasyQueryable2<>(entityQueryable2);
}
@Override
public Queryable2 rightJoin(Queryable joinQueryable, SQLExpression2, SQLWherePredicate> on) {
ClientQueryable2 entityQueryable2 = entityQueryable.rightJoin(joinQueryable.getClientQueryable(), (wherePredicate1, wherePredicate2) -> {
on.apply(new SQLWherePredicateImpl<>(wherePredicate1), new SQLWherePredicateImpl<>(wherePredicate2));
});
return new EasyQueryable2<>(entityQueryable2);
}
@Override
public Queryable2 innerJoin(Class joinClass, SQLExpression2, SQLWherePredicate> on) {
ClientQueryable2 entityQueryable2 = entityQueryable.innerJoin(joinClass, (wherePredicate1, wherePredicate2) -> {
on.apply(new SQLWherePredicateImpl<>(wherePredicate1), new SQLWherePredicateImpl<>(wherePredicate2));
});
return new EasyQueryable2<>(entityQueryable2);
}
@Override
public Queryable2 innerJoin(Queryable joinQueryable, SQLExpression2, SQLWherePredicate> on) {
ClientQueryable2 entityQueryable2 = entityQueryable.innerJoin(joinQueryable.getClientQueryable(), (wherePredicate1, wherePredicate2) -> {
on.apply(new SQLWherePredicateImpl<>(wherePredicate1), new SQLWherePredicateImpl<>(wherePredicate2));
});
return new EasyQueryable2<>(entityQueryable2);
}
@Override
public Queryable union(Collection> unionQueries) {
if (EasyCollectionUtil.isEmpty(unionQueries)) {
return this;
}
ClientQueryable unionQueryable = entityQueryable.union(EasyCollectionUtil.select(unionQueries, (queryable, i) -> queryable.getClientQueryable()));
return new EasyQueryable<>(unionQueryable);
}
@Override
public Queryable unionAll(Collection> unionQueries) {
if (EasyCollectionUtil.isEmpty(unionQueries)) {
return this;
}
ClientQueryable unionQueryable = entityQueryable.unionAll(EasyCollectionUtil.select(unionQueries, (queryable, i) -> queryable.getClientQueryable()));
return new EasyQueryable<>(unionQueryable);
}
@Override
public Queryable useLogicDelete(boolean enable) {
entityQueryable.useLogicDelete(enable);
return this;
}
@Override
public Queryable configure(SQLExpression1 configurer) {
entityQueryable.configure(configurer);
return this;
}
@Override
public Queryable noInterceptor() {
entityQueryable.noInterceptor();
return this;
}
@Override
public Queryable useInterceptor(String name) {
entityQueryable.useInterceptor(name);
return this;
}
@Override
public Queryable noInterceptor(String name) {
entityQueryable.noInterceptor(name);
return this;
}
@Override
public Queryable useInterceptor() {
entityQueryable.useInterceptor();
return this;
}
@Override
public Queryable asTracking() {
entityQueryable.asTracking();
return this;
}
@Override
public Queryable asNoTracking() {
entityQueryable.asNoTracking();
return this;
}
@Override
public Queryable asTable(Function tableNameAs) {
entityQueryable.asTable(tableNameAs);
return this;
}
@Override
public Queryable asSchema(Function schemaAs) {
entityQueryable.asSchema(schemaAs);
return this;
}
@Override
public Queryable asAlias(String alias) {
entityQueryable.asAlias(alias);
return this;
}
@Override
public Queryable asTableLink(Function linkAs) {
entityQueryable.asTableLink(linkAs);
return this;
}
@Override
public Queryable asTableSegment(BiFunction segmentAs) {
entityQueryable.asTableSegment(segmentAs);
return this;
}
@Override
public Queryable useShardingConfigure(int maxShardingQueryLimit, ConnectionModeEnum connectionMode) {
entityQueryable.useShardingConfigure(maxShardingQueryLimit, connectionMode);
return this;
}
@Override
public Queryable useMaxShardingQueryLimit(int maxShardingQueryLimit) {
entityQueryable.useMaxShardingQueryLimit(maxShardingQueryLimit);
return this;
}
@Override
public Queryable useConnectionMode(ConnectionModeEnum connectionMode) {
entityQueryable.useConnectionMode(connectionMode);
return this;
}
@Override
public Queryable queryLargeColumn(boolean queryLarge) {
entityQueryable.queryLargeColumn(queryLarge);
return this;
}
@Override
public Queryable filterConfigure(ValueFilter valueFilter) {
entityQueryable.filterConfigure(valueFilter);
return this;
}
@Override
public MethodQuery forEach(Consumer mapConfigure) {
entityQueryable.forEach(mapConfigure);
return this;
}
}