73 Star 929 Fork 183

GVPaizuda/MongoPlus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Facet.java 2.47 KB
一键复制 编辑 原始数据 按行查看 历史
package com.anwen.mongo.aggregate.pipeline;
import com.anwen.mongo.aggregate.Aggregate;
import com.anwen.mongo.aggregate.AggregateWrapper;
import com.anwen.mongo.aggregate.LambdaAggregateWrapper;
import com.anwen.mongo.support.SFunction;
import org.bson.conversions.Bson;
import java.util.List;
/**
* 用于 $facet 管道阶段的类,封装Facet,支持lambda
* @author anwen
* @date 2024/6/11 下午8:05
*/
public class Facet extends com.mongodb.client.model.Facet {
/**
* $facet阶段
* @param name facet名称
* @param pipeline facet管道
* @author anwen
* @date 2024/6/11 下午8:10
*/
public <T> Facet(SFunction<T,?> name, List<? extends Bson> pipeline) {
super(name.getFieldNameLine(), pipeline);
}
/**
* $facet阶段
* @param name facet名称
* @param pipeline facet管道
* @author anwen
* @date 2024/6/11 下午8:10
*/
public <T> Facet(SFunction<T,?> name, Bson... pipeline) {
super(name.getFieldNameLine(), pipeline);
}
/**
* $facet阶段
* @param name facet名称
* @param aggregateChainWrapper 管道Wrapper
* @author anwen
* @date 2024/6/11 下午8:10
*/
public Facet(String name, Aggregate<?> aggregateChainWrapper){
super(name, aggregateChainWrapper.getAggregateConditionList());
}
/**
* $facet阶段
* @param name facet名称
* @param function 管道Wrapper
* @author anwen
* @date 2024/6/11 下午8:10
*/
public Facet(String name, SFunction<LambdaAggregateWrapper<AggregateWrapper>,LambdaAggregateWrapper<AggregateWrapper>> function){
super(name, function.apply(new AggregateWrapper()).getAggregateConditionList());
}
/**
* $facet阶段
* @param name facet名称
* @param aggregateChainWrapper 管道Wrapper
* @author anwen
* @date 2024/6/11 下午8:10
*/
public <T> Facet(SFunction<T,?> name, Aggregate<?> aggregateChainWrapper){
super(name.getFieldNameLine(), aggregateChainWrapper.getAggregateConditionList());
}
/**
* $facet阶段
* @param name facet名称
* @param function 管道Wrapper
* @author anwen
* @date 2024/6/11 下午8:10
*/
public <T,R> Facet(SFunction<T,?> name, SFunction<LambdaAggregateWrapper<AggregateWrapper>,LambdaAggregateWrapper<AggregateWrapper>> function){
super(name.getFieldNameLine(), function.apply(new AggregateWrapper()).getAggregateConditionList());
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/aizuda/mongo-plus.git
git@gitee.com:aizuda/mongo-plus.git
aizuda
mongo-plus
MongoPlus
master

搜索帮助