mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix code
This commit is contained in:
parent
9285ccbd5f
commit
620b493ebc
@ -1,6 +1,6 @@
|
||||
#### 说明
|
||||
### 说明
|
||||
|
||||
1. 请确认你提交的PR是到'v5-dev'分支,否则我会手动修改代码并关闭PR。
|
||||
1. 请确认你提交的PR是到'v6-dev'分支,否则我会手动修改代码并关闭PR。
|
||||
2. 请确认没有更改代码风格(如tab缩进)
|
||||
3. 新特性添加请确认注释完备,如有必要,请在src/test/java下添加Junit测试用例
|
||||
|
||||
|
4
.github/codeql-analysis.yml
vendored
4
.github/codeql-analysis.yml
vendored
@ -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'
|
||||
|
||||
|
@ -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 methods,Unless 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.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
14
README.md
14
README.md
@ -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,请不要诧异,这是我们保持问题处理整洁的一种方式,你依旧可以继续讨论,当有讨论结果时我们会重新打开。
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -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(报告漏洞)
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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对象
|
||||
*
|
||||
|
@ -31,6 +31,7 @@
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- 测试特殊算法 -->
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user