java编写字符串连接程序注释_Java 注解自动化处理对应关系实现注释代码化

public class EsQuery { private static int DEFAULT_SIZE =100; private final Map termFilter;private final Map rangeFilter;private final Map matchFilter;private int size;private String orderBy =null;private String order =null; // query 查询语法, 是否需要 filtered, filter 这两层// 5.x 版本不再需要这两层private boolean isNeedFilterLayer =true; private Integer from; private final Map mustNotTermFilter; private final Map shouldTermFilter;private Integer shouldMatchMinimum; private List includes;private List excludes; public EsQuery() {this.termFilter =new HashMap<>();this.rangeFilter =new HashMap();this.matchFilter =new HashMap();this.mustNotTermFilter =new HashMap<>();this.shouldTermFilter =new HashedMap();this.size = DEFAULT_SIZE;this.includes =new ArrayList<>();this.excludes =new ArrayList<>();} public EsQuery addTermFilter(String key, Object value) {this.termFilter.put(key, value);return this;} public EsQuery addMustNotTermFilter(String key, Object value) {this.mustNotTermFilter.put(key, value);return this;} public EsQuery addAllMustNotTermFilter(Map mustNot) {if (mustNot !=null && !mustNot.isEmpty()) {this.mustNotTermFilter.putAll(mustNot);}return this;} public EsQuery addShouldTermFilter(String key, Object value) {this.shouldTermFilter.put(key, value);return this;} public EsQuery addAllShouldTermFilter(Map should) {if (should !=null && !should.isEmpty()) {this.shouldTermFilter.putAll(should);}return this;} public EsQuery addRangeFilter(String key,long gte,long lte){this.rangeFilter.put(key,new Range(gte, lte));return this;} public EsQuery addMatchFilter(String key, Match value) {this.matchFilter.put(key, value);return this;} public EsQuery addIncludeFields(List includes) {this.includes.addAll(includes);return this;} public EsQuery addExcludeFields(List excludes) {this.excludes.addAll(excludes);return this;}  @Overridepublic String toString() {return toJsonString();} public String toJsonString() {Map finalQuery =new HashMap<>();Map queryMap =new HashMap<>();Map filteredMap =new HashMap<>();Map filterMap =new HashMap<>();Map boolMap =new HashMap<>(); List mustList = obtainTermFilterList(this.termFilter); List mustNotList = obtainTermFilterList(this.mustNotTermFilter); List shouldList = obtainTermFilterList(this.shouldTermFilter); if(!this.rangeFilter.isEmpty()){for(Map.Entry e:this.rangeFilter.entrySet()){Map rangeMap =new HashMap<>();Map rangeEntityMap =new HashMap<>();rangeEntityMap.put(e.getKey(), e.getValue().toMap());rangeMap.put(Constant.range, rangeEntityMap);mustList.add(rangeMap);}} if(!this.matchFilter.isEmpty()){this.matchFilter.forEach((key, match) -> {Map matchEntityMap =new HashMap<>();Map matchMap =new HashMap<>();Map subMatchMap =new HashMap<>();matchEntityMap.put(Constant.query, match.getQuery());matchEntityMap.put(Constant.should_minum, match.getMinimumShouldMatch());matchMap.put(key, matchEntityMap);subMatchMap.put(Constant.match, matchMap);mustList.add(subMatchMap);});} boolMap.put(Constant.must, mustList);if (!mustNotList.isEmpty())boolMap.put(Constant.mustNot, mustNotList);if (!shouldList.isEmpty()) {// 有 minimum_should_match 不带过滤器boolMap.put(Constant.should, shouldList);boolMap.put(Constant.should_minum, shouldMatchMinimum);queryMap.put(Constant.bool, boolMap);}else {if (isNeedFilterLayer) {filterMap.put(Constant.bool, boolMap);filteredMap.put(Constant.filter, filterMap);queryMap.put(Constant.filtered, filteredMap);}else {queryMap.put(Constant.bool, boolMap);}}finalQuery.put(Constant.query, queryMap); Map orderMap =new HashMap<>();Map orderItem =new HashMap<>(); if(order !=null && orderBy !=null){orderItem.put(Constant.order,this.order);orderMap.put(this.orderBy, orderItem);finalQuery.put(Constant.sort, orderMap);} Map source =new HashMap<>();if (!includes.isEmpty()) {source.put(Constant.includes,this.includes);}if (!excludes.isEmpty()) {source.put(Constant.excludes,this.excludes);}if (!source.isEmpty()) {finalQuery.put(Constant.source, source);} finalQuery.put(Constant.size,this.size);if (from !=null) {finalQuery.put(Constant.from, from.intValue());}return JSON.toJSONString(finalQuery);} public List obtainTermFilterList(Map termFilter) {List termFilterList =new ArrayList<>();for (Map.Entry e: termFilter.entrySet()){Map termMap =new HashMap<>();Map itemMap =new HashMap<>();itemMap.put(e.getKey(), e.getValue());if(e.getValue()instanceof List){termMap.put(Constant.terms, itemMap);}else{termMap.put(Constant.term, itemMap);}termFilterList.add(termMap);}return termFilterList;} public String getOrderBy() {return orderBy;} public void setOrderBy(String orderBy) {this.orderBy = orderBy;} public String getOrder() {return order;} public void setOrder(String order) {this.order = order;} public int getSize() {return size;} public void setSize(int size) {this.size = size;} public Integer getFrom() {return from;} public void setFrom(Integer from) {this.from = from;} public Map getTermFilter() {return Collections.unmodifiableMap(termFilter);} public Map getRangeFilter() {return Collections.unmodifiableMap(rangeFilter);} public Map getMustNotTermFilter() {return Collections.unmodifiableMap(mustNotTermFilter);} public Map getShouldTermFilter() {return Collections.unmodifiableMap(shouldTermFilter);} public Map getMatchFilter() {return matchFilter;} public void setShouldMatchMinimum(Integer shouldMatchMinimum) {this.shouldMatchMinimum = shouldMatchMinimum;} public Integer getShouldMatchMinimum() {return shouldMatchMinimum;} public Map getRangeMap(String key) {return Collections.unmodifiableMap(rangeFilter.get(key).toMap());} public List getIncludes() {return Collections.unmodifiableList(includes);} public boolean isNeedFilterLayer() {return isNeedFilterLayer;} public void setNeedFilterLayer(boolean needFilterLayer) {isNeedFilterLayer = needFilterLayer;} @Overridepublic boolean equals(Object o) {// for you to write} @Overridepublic int hashCode() {// for you to write}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541419.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

getlanguage_Java语言环境getLanguage()方法与示例

getlanguage区域设置类getLanguage()方法 (Locale Class getLanguage() method) getLanguage() method is available in java.util package. getLanguage()方法在java.util包中可用。 getLanguage() method is used to retrieve this Locale language code and the language co…

[转]Anaconda

安装 Anaconda Anaconda 可用于 Windows、Mac OS X 和 Linux。可以在 https://www.continuum.io/down... 上找到安装程序和安装说明。 如果计算机上已经安装了 Python&#xff0c;这不会有任何影响。实际上&#xff0c;脚本和程序使用的默认 Python 是 Anaconda 附带的 Python。…

win10 iot core java_Windows 10 IoT Core 正式版初体验

今天收到Windows 10 IoT Core Team邮件&#xff0c;Windows 10 IoT Core正式发布。以下记录了今天在Raspberry Pi 2上的体验过程&#xff1a;准备工作一台运行着正版Windows 10且版本不小于10240的个人PCVisual Studio 2015 版本不小于14.0.23107.0 D14Rel Install Visual Stud…

filterwriter_Java FilterWriter flush()方法与示例

filterwriterFilterWriter类flush()方法 (FilterWriter Class flush() method) flush() method is available in java.io package. flush()方法在java.io包中可用。 flush() method is used to flush out the string from this FilterWriter stream. flush()方法用于从此Filter…

VUE2 第五天学习--过渡效果

阅读目录 1.理解VUE---过渡效果回到顶部1.理解VUE---过渡效果 1. 过渡的-css-类名会有4个(css) 类名在 enter/leave 在过渡中切换。1. v-enter: 进入过渡的开始状态。在元素被插入时生效&#xff0c;在下一个帧移除。2. v-enter-active: 进入过渡的结束状态。在元素被插入时生效…

java 集合addall_Java集合的addAll()方法和示例

java 集合addall集合类的addAll()方法 (Collections Class addAll() method) addAll() Method is available in java.lang package. addAll()方法在java.lang包中可用。 addAll() Method is used to put all the given elements(ele) to the given collection (co). addAll()方…

国家可持续发展议程创新示范区创建工作推进会在北京召开

2019独角兽企业重金招聘Python工程师标准>>> 为推进地方申报国家可持续发展议程创新示范区相关工作&#xff0c;根据国家可持续发展议程创新示范区创建工作的进展及需求&#xff0c;2017年4月23日—25日&#xff0c;科技部社会发展科技司、中国21世纪议程管理中心在…

java控制台打印图片_java——控制台输入打印图形

1. 打印直角三角形需求说明&#xff1a;从控制台输入直角三角形的高度(行数)。每行*的数目依次为1、3、5、7等。实现思路&#xff1a;外层循环控制行数&#xff0c;根据用户输入的行数得到外层循环条件分析每行打印的内容&#xff1a;每一行均打印*号&#xff0c;第i行的*号数为…

Java日历compareTo()方法与示例

日历类的compareTo()方法 (Calendar Class compareTo() method) compareTo() method is available in java.util package. compareTo()方法在java.util包中可用。 compareTo() method is used to compare two Calendar objects or in other words, we can say this method is u…

在struts2中配置自定义拦截器放行多个方法

源码&#xff1a; 自定义的拦截器类&#xff1a; //自定义拦截器类:LoginInterceptor ; package com.java.action.interceptor; import javax.servlet.http.HttpSession; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionInvocation;im…

java多态和泛型_Java面向对象(二) 接口、多态和泛型

一、接口二、多态多态是同一个行为具有多个不同表现形式或形态的能力。2.1 类型转换转换方式隐式 向上转型对于基本数据类型&#xff0c;存储容量低的可自动向存储容量高的类型转换对于引用变量&#xff0c;子类可被转换为超类&#xff0c;可被赋给所属类实现的接口的引用显式 …

Java ArrayList contains()方法及示例

ArrayList类contains()方法 (ArrayList Class contains() method) contains() method is available in java.util package. contains()方法在java.util包中可用。 contains() method is used to check whether this Arraylist contains the given object or not. contains()方法…

BlockingQueue详解

前言&#xff1a; 在新增的Concurrent包中&#xff0c;BlockingQueue很好的解决了多线程中&#xff0c;如何高效安全“传输”数据的问题。通过这些高效并且线程安全的队列类&#xff0c;为我们快速搭建高质量的多线程程序带来极大的便利。本文详细介绍了BlockingQueue家庭中的所…

java isempty_Java ArrayDeque isEmpty()方法与示例

java isemptyArrayDeque类isEmpty()方法 (ArrayDeque Class isEmpty() method) isEmpty() Method is available in java.lang package. isEmpty()方法在java.lang包中可用。 isEmpty() Method is used to check whether this deque is "empty" or "non-empty&qu…

[QGLViewer]3D场景鼠标点击位置

重载鼠标事件&#xff1a; void AxMapControl::mousePressEvent(QMouseEvent* e) {switch(currentTool){case AX_DRAW_DIRECTION:{if (e->button() Qt::LeftButton) {QPoint screenPte->pos();qglviewer::Vec orig1, dir1;camera()->convertClickToLine(screenPt, or…

elispce导入java项目_emacs的java编程环境设置(jdee,lib,cedet,ecb

1&#xff1a;下载jdee,lib,ecb。(已安装cedet就不用再安了)2&#xff1a;解压缩放入load-path目录。然后load&#xff0c;require。(add-to-list load-path "~/.emacs.d/lisp/jdee-2.4.0.1/lisp")(add-to-list load-path "~/.emacs.d/lisp/elib-1.0")(add…

element 项目 示例_Java ArrayDeque element()方法与示例

element 项目 示例ArrayDeque类element()方法 (ArrayDeque Class element() method) element() Method is available in java.lang package. element()方法在java.lang包中可用。 element() Method is used to retrieve the first element of the deque but without removing t…

can收发器 rx_CANOpen系列教程03 _CAN收发器功能、原理及作用

1写在前面前面文章是从大方向介绍了CAN网络&#xff0c;让大家对CAN网络有一定的认识。本文将范围缩小&#xff0c;讲述整个CAN网络其中的一个CAN收发器。如下图标记出来的部分&#xff1a;本文结合众多初学者容易产生的疑问来讲述CAN收发器相关的知识点&#xff0c;大概有如下…

操作系统文件分配策略_操作系统中的文件分配方法

操作系统文件分配策略分配方法 (Allocation Method) The allocation method defines how the files are stored in the disk blocks. The direct access nature of the disks gives us the flexibility to implement the files. In many cases, different files or many files …

简述container与container-fluid的区别

在bootstrap中的布局容器一栏中&#xff0c;提供了container与container-fluid两种容器&#xff0c;其官方解释为&#xff1a; .container 类用于固定宽度并支持响应式布局的容器。 .container-fluid 类用于 100% 宽度&#xff0c;占据全部视口&#xff08;viewport&#xff09…