This commit is contained in:
Looly 2022-04-29 00:32:45 +08:00
parent 9285ccbd5f
commit 620b493ebc
9 changed files with 59 additions and 24 deletions

View File

@ -1,6 +1,6 @@
#### 说明
### 说明
1. 请确认你提交的PR是到'v5-dev'分支否则我会手动修改代码并关闭PR。
1. 请确认你提交的PR是到'v6-dev'分支否则我会手动修改代码并关闭PR。
2. 请确认没有更改代码风格如tab缩进
3. 新特性添加请确认注释完备如有必要请在src/test/java下添加Junit测试用例

View File

@ -13,10 +13,10 @@ name: "CodeQL"
on:
push:
branches: [ v5-dev ]
branches: [ v6-dev ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ v5-dev ]
branches: [ v6-dev ]
schedule:
- cron: '45 6 * * 1'

View File

@ -25,7 +25,7 @@
<img src="https://app.codacy.com/project/badge/Grade/8a6897d9de7440dd9de8804c28d2871d"/>
</a>
<a href="https://codecov.io/gh/dromara/hutool">
<img src="https://codecov.io/gh/dromara/hutool/branch/v5-master/graph/badge.svg" />
<img src="https://codecov.io/gh/dromara/hutool/branch/v6-master/graph/badge.svg" />
</a>
<a target="_blank" href="https://gitter.im/hutool/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge">
<img src="https://badges.gitter.im/hutool/Lobby.svg" />
@ -178,8 +178,8 @@ Hutool's source code is divided into two branches:
| branch | description |
|-----------|---------------------------------------------------------------|
| v5-master | The master branch, the branch used by the release version, is the same as the jar committed to the central repository and does not receive any pr or modifications. |
| v5-dev | Development branch, which defaults to the next SNAPSHOT version, accepts modifications or pr |
| v6-master | The master branch, the branch used by the release version, is the same as the jar committed to the central repository and does not receive any pr or modifications. |
| v6-dev | Development branch, which defaults to the next SNAPSHOT version, accepts modifications or pr |
### 🐞Provide feedback or suggestions on bugs
@ -195,7 +195,7 @@ Hutool welcomes anyone to contribute code to Hutool, but the author suffers from
1. Improve the comments, especially each new method should follow the Java documentation specification to indicate the method description, parameter description, return value description and other information, if necessary, please add unit tests, if you want, you can also add your name.
2. Code indentation according to Eclipse.
3. Newly added methods do not use third-party library methodsUnless the method tool is add to the '**extra module**'.
4. Please pull request to the `v5-dev` branch. Hutool uses a new branch after 5.x: `v5-master` is the master branch, which indicates the version of the central library that has been released, and this branch does not allow pr or modifications.
4. Please pull request to the `v6-dev` branch. Hutool uses a new branch after 5.x: `v6-master` is the master branch, which indicates the version of the central library that has been released, and this branch does not allow pr or modifications.
-------------------------------------------------------------------------------

View File

@ -25,7 +25,7 @@
<img src="https://app.codacy.com/project/badge/Grade/8a6897d9de7440dd9de8804c28d2871d"/>
</a>
<a href="https://codecov.io/gh/dromara/hutool">
<img src="https://codecov.io/gh/dromara/hutool/branch/v5-master/graph/badge.svg" />
<img src="https://codecov.io/gh/dromara/hutool/branch/v6-master/graph/badge.svg" />
</a>
<a target="_blank" href="https://gitter.im/hutool/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge">
<img src="https://badges.gitter.im/hutool/Lobby.svg" />
@ -164,7 +164,7 @@ implementation 'cn.hutool:hutool-all:6.0.0.M1'
### 🚽编译安装
访问Hutool的Gitee主页[https://gitee.com/dromara/hutool](https://gitee.com/dromara/hutool)
下载整个项目源码v5-master或v5-dev分支都可然后进入Hutool项目目录执行
下载整个项目源码v6-master或v6-dev分支都可然后进入Hutool项目目录执行
```sh
./hutool.sh install
@ -182,8 +182,8 @@ Hutool的源码分为两个分支功能如下
| 分支 | 作用 |
|-----------|---------------------------------------------------------------|
| v5-master | 主分支release版本使用的分支与中央库提交的jar一致不接收任何pr或修改 |
| v5-dev | 开发分支默认为下个版本的SNAPSHOT版本接受修改或pr |
| v6-master | 主分支release版本使用的分支与中央库提交的jar一致不接收任何pr或修改 |
| v6-dev | 开发分支默认为下个版本的SNAPSHOT版本接受修改或pr |
### 🐞提供bug反馈或建议
@ -196,8 +196,8 @@ Hutool的源码分为两个分支功能如下
1. 在Gitee或者Github上fork项目到自己的repo
2. 把fork过去的项目也就是你的项目clone到你的本地
3. 修改代码记得一定要修改v5-dev分支
4. commit后push到自己的库v5-dev分支
3. 修改代码记得一定要修改v6-dev分支
4. commit后push到自己的库v6-dev分支
5. 登录Gitee或Github在你首页可以看到一个 pull request 按钮,点击它,填写一些说明信息,然后提交即可。
6. 等待维护者合并
@ -208,7 +208,7 @@ Hutool欢迎任何人为Hutool添砖加瓦贡献代码不过维护者是
1. 注释完备尤其每个新增的方法应按照Java文档规范标明方法说明、参数说明、返回值说明等信息必要时请添加单元测试如果愿意也可以加上你的大名。
2. Hutool的缩进按照Eclipse~~不要跟我说IDEA多好用维护者非常懒学不会~~IDEA真香改了Eclipse快捷键后舒服多了默认tab缩进所以请遵守不要和我争执空格与tab的问题这是一个病人的习惯
3. 新加的方法不要使用第三方库的方法Hutool遵循无依赖原则除非在extra模块中加方法工具
4. 请pull request到`v5-dev`分支。Hutool在5.x版本后使用了新的分支`v5-master`是主分支表示已经发布中央库的版本这个分支不允许pr也不允许修改。
4. 请pull request到`v6-dev`分支。Hutool在5.x版本后使用了新的分支`v6-master`是主分支表示已经发布中央库的版本这个分支不允许pr也不允许修改。
5. 我们如果关闭了你的issue或pr请不要诧异这是我们保持问题处理整洁的一种方式你依旧可以继续讨论当有讨论结果时我们会重新打开。
-------------------------------------------------------------------------------

View File

@ -3,10 +3,8 @@
## Supported Versions支持的版本
| Version | Supported |
| ------- | ------------------ |
| 5.x.x | :white_check_mark: |
| 4.x.x | :x: |
| 3.x.x | :x: |
|---------| ------------------ |
| 6.x.x | :white_check_mark: |
## Reporting a Vulnerability报告漏洞

View File

@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -561,13 +562,23 @@ public class BeanUtil {
// --------------------------------------------------------------------------------------------- beanToMap
/**
* 对象转Map不进行驼峰转下划线不忽略值为空的字段
* 将bean的部分属性转换成map<br>
* 可选拷贝哪些属性值默认是不忽略值为{@code null}的值的
*
* @param bean bean对象
* @param bean bean
* @param properties 需要拷贝的属性值{@code null}或空表示拷贝所有值
* @return Map
* @since 5.8.0
*/
public static Map<String, Object> beanToMap(Object bean) {
return beanToMap(bean, false, false);
public static Map<String, Object> beanToMap(Object bean, String... properties) {
Editor<String> keyEditor = null;
if(ArrayUtil.isNotEmpty(properties)){
final Set<String> propertiesSet = CollUtil.set(false, properties);
keyEditor = property -> propertiesSet.contains(property) ? property : null;
}
// 指明了要复制的属性 所以不忽略null值
return beanToMap(bean, new LinkedHashMap<>(properties.length, 1), false, keyEditor);
}
/**

View File

@ -6,7 +6,9 @@ import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 单例类<br>
@ -90,6 +92,30 @@ public final class Singleton {
POOL.put(key, obj);
}
/**
* 判断某个类的对象是否存在
*
* @param clazz
* @param params 构造参数
* @return 是否存在
*/
public static boolean exists(Class<?> clazz, Object... params){
if (null != clazz){
final String key = buildKey(clazz.getName(), params);
return POOL.containsKey(key);
}
return false;
}
/**
* 获取单例池中存在的所有类
*
* @return 非重复的类集合
*/
public static Set<Class<?>> getExistClass(){
return POOL.values().stream().map(Object::getClass).collect(Collectors.toSet());
}
/**
* 移除指定Singleton对象
*

View File

@ -31,6 +31,7 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
<!-- 测试特殊算法 -->
<dependency>

View File

@ -144,7 +144,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.10.0</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>