日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2025/3/11 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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}

總結

以上是生活随笔為你收集整理的java编写字符串连接程序注释_Java 注解自动化处理对应关系实现注释代码化的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。