Skip to content

Commit

Permalink
v6.5.9
Browse files Browse the repository at this point in the history
v6.5.9
  • Loading branch information
839128 authored Oct 17, 2022
2 parents f4f598a + ba976f0 commit b1fec68
Show file tree
Hide file tree
Showing 519 changed files with 9,401 additions and 19,488 deletions.
Empty file added CHANGELOG.md
Empty file.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=org.aoju">
<img src="https://img.shields.io/badge/maven--central-v6.5.8-blue.svg?label=Maven%20Central" />
<img src="https://img.shields.io/badge/maven--central-v6.5.9-blue.svg?label=Maven%20Central" />
</a>
<a target="_blank" href="https://travis-ci.org/aoju/bus">
<img src="https://travis-ci.com/aoju/bus.svg?branch=main">
Expand Down Expand Up @@ -97,7 +97,7 @@ Bus (应用/服务总线) 是一个基础框架、服务套件,它基于Java17
<dependency>
<groupId>org.aoju</groupId>
<artifactId>bus-all</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion bus-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.aoju</groupId>
<artifactId>bus-all</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.aoju</groupId>
<artifactId>bus-base</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.aoju</groupId>
<artifactId>bus-bom</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
<packaging>pom</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.aoju</groupId>
<artifactId>bus-cache</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
22 changes: 13 additions & 9 deletions bus-cache/src/main/java/org/aoju/bus/cache/support/Addables.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.aoju.bus.core.toolkit.CollKit;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand All @@ -49,25 +50,26 @@ public static Addable newAddable(Class<?> type, int size) {

public static Collection newCollection(Class<?> type, Collection initCollection) {
try {
Collection collection = (Collection) type.newInstance();
Collection collection = (Collection) type.getConstructor().newInstance();
if (CollKit.isNotEmpty(initCollection)) {
collection.addAll(initCollection);
}

return collection;
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException e) {
throw new RuntimeException("could not invoke collection: " + type.getName() + "'s no param (default) constructor!", e);
}
}

public static Map newMap(Class<?> type, Map initMap) {
try {
Map map = (Map) type.newInstance();
Map map = (Map) type.getConstructor().newInstance();
if (CollKit.isNotEmpty(initMap)) {
map.putAll(initMap);
}
return map;
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException e) {
throw new RuntimeException("could not invoke map: " + type.getName() + "'s no param (default) constructor!", e);
}
}
Expand Down Expand Up @@ -113,8 +115,9 @@ private static class CollectionAddable implements Addable<Collection> {
@Override
public Addable init(Class<Collection> type, int initSize) {
try {
this.instance = type.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
this.instance = type.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException e) {
throw new RuntimeException("could not invoke collection: " + type.getName() + "'s no param (default) constructor!", e);
}

Expand All @@ -140,8 +143,9 @@ private static class MapAddable implements Addable<Map> {
@Override
public Addable init(Class<Map> type, int initSize) {
try {
this.instance = type.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
this.instance = type.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException e) {
throw new RuntimeException("could not invoke Map: " + type.getName() + "'s no param (default) constructor!", e);
}

Expand Down
2 changes: 1 addition & 1 deletion bus-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dependency>
<groupId>org.aoju</groupId>
<artifactId>bus-core</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion bus-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.aoju</groupId>
<artifactId>bus-core</artifactId>
<version>6.5.8</version>
<version>6.5.9</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-core/src/main/java/org/aoju/bus/core/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class Version {
* @return 项目的版本号
*/
public static String get() {
return "6.5.8.RELEASE";
return "6.5.9.RELEASE";
}

/**
Expand Down
6 changes: 3 additions & 3 deletions bus-core/src/main/java/org/aoju/bus/core/beans/BeanCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
********************************************************************************/
package org.aoju.bus.core.beans;

import org.aoju.bus.core.lang.function.Func0;
import org.aoju.bus.core.lang.function.XSupplier;
import org.aoju.bus.core.map.WeakMap;

/**
Expand Down Expand Up @@ -53,8 +53,8 @@ public enum BeanCache {
* @param supplier 对象不存在时创建对象的函数
* @return 属性名和{@link BeanDesc}映射
*/
public BeanDesc getBeanDesc(Class<?> beanClass, Func0<BeanDesc> supplier) {
return bdCache.computeIfAbsent(beanClass, supplier);
public BeanDesc getBeanDesc(Class<?> beanClass, XSupplier<BeanDesc> supplier) {
return bdCache.computeIfAbsent(beanClass, (key) -> supplier.get());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
********************************************************************************/
package org.aoju.bus.core.beans;

import org.aoju.bus.core.lang.function.Func0;
import org.aoju.bus.core.lang.function.XSupplier;
import org.aoju.bus.core.map.ReferenceMap;
import org.aoju.bus.core.map.WeakMap;

Expand Down Expand Up @@ -68,8 +68,8 @@ public Map<String, PropertyDescriptor> getPropertyDescriptorMap(Class<?> beanCla
public Map<String, PropertyDescriptor> getPropertyDescriptorMap(
Class<?> beanClass,
boolean ignoreCase,
Func0<Map<String, PropertyDescriptor>> supplier) {
return getCache(ignoreCase).computeIfAbsent(beanClass, (key) -> supplier.callWithRuntimeException());
XSupplier<Map<String, PropertyDescriptor>> supplier) {
return getCache(ignoreCase).computeIfAbsent(beanClass, (key) -> supplier.get());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public abstract class AbstractCopier<S, T> implements Copier<T> {
public AbstractCopier(S source, T target, CopyOptions copyOptions) {
this.source = source;
this.target = target;
this.copyOptions = ObjectKit.defaultIfNull(copyOptions, CopyOptions::create);
this.copyOptions = ObjectKit.defaultIfNull(copyOptions, CopyOptions::of);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.aoju.bus.core.beans.PropertyDesc;
import org.aoju.bus.core.lang.Assert;
import org.aoju.bus.core.lang.mutable.MutableEntry;
import org.aoju.bus.core.toolkit.BeanKit;
import org.aoju.bus.core.toolkit.TypeKit;

Expand Down Expand Up @@ -70,38 +71,43 @@ public T copy() {
"Target class [{}] not assignable to Editable class [{}]", actualEditable.getName(), copyOptions.editable.getName());
actualEditable = copyOptions.editable;
}
final Map<String, PropertyDesc> targetPropertyDescMap = BeanKit.getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);

final Map<String, PropertyDesc> sourcePropertyDescMap = BeanKit.getBeanDesc(source.getClass()).getPropMap(copyOptions.ignoreCase);
sourcePropertyDescMap.forEach((sFieldName, sDesc) -> {
final Map<String, PropertyDesc> targetPropDescMap = BeanKit.getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
final Map<String, PropertyDesc> sourcePropDescMap = BeanKit.getBeanDesc(source.getClass()).getPropMap(copyOptions.ignoreCase);
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
if (null == sFieldName || false == sDesc.isReadable(copyOptions.transientSupport)) {
// 字段空或不可读,跳过
return;
}

sFieldName = copyOptions.editFieldName(sFieldName);
// 检查源对象属性是否过滤属性
Object sValue = sDesc.getValue(this.source);
if (false == copyOptions.testPropertyFilter(sDesc.getField(), sValue)) {
return;
}

// 编辑键值对
final MutableEntry<String, Object> entry = copyOptions.editField(sFieldName, sValue);
if (null == entry) {
return;
}
sFieldName = entry.getKey();
// 对key做转换,转换后为null的跳过
if (null == sFieldName) {
return;
}
sValue = entry.getValue();

// 检查目标字段可写性
final PropertyDesc tDesc = targetPropertyDescMap.get(sFieldName);
// 目标字段检查放在键值对编辑之后,因为键可能被编辑修改
final PropertyDesc tDesc = targetPropDescMap.get(sFieldName);
if (null == tDesc || false == tDesc.isWritable(this.copyOptions.transientSupport)) {
// 字段不可写,跳过之
return;
}

// 检查源对象属性是否过滤属性
Object sValue = sDesc.getValue(this.source);
if (false == copyOptions.testPropertyFilter(sDesc.getField(), sValue)) {
return;
}

// 获取目标字段真实类型并转换源值
final Type fieldType = TypeKit.getActualType(this.targetType, tDesc.getFieldType());
sValue = this.copyOptions.convertField(fieldType, sValue);
sValue = copyOptions.editFieldValue(sFieldName, sValue);

// 目标赋值
tDesc.setValue(this.target, sValue, copyOptions.ignoreNullValue, copyOptions.ignoreError, copyOptions.override);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.aoju.bus.core.beans.PropertyDesc;
import org.aoju.bus.core.lang.Assert;
import org.aoju.bus.core.lang.mutable.MutableEntry;
import org.aoju.bus.core.toolkit.BeanKit;
import org.aoju.bus.core.toolkit.TypeKit;

Expand Down Expand Up @@ -69,30 +70,35 @@ public Map copy() {
actualEditable = copyOptions.editable;
}

final Map<String, PropertyDesc> sourcePropertyDescMap = BeanKit.getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
sourcePropertyDescMap.forEach((sFieldName, sDesc) -> {
final Map<String, PropertyDesc> sourcePropDescMap = BeanKit.getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
if (null == sFieldName || false == sDesc.isReadable(copyOptions.transientSupport)) {
// 字段空或不可读,跳过
return;
}

sFieldName = copyOptions.editFieldName(sFieldName);
// 对key做转换,转换后为null的跳过
if (null == sFieldName) {
return;
}

// 检查源对象属性是否过滤属性
Object sValue = sDesc.getValue(this.source);
if (false == copyOptions.testPropertyFilter(sDesc.getField(), sValue)) {
return;
}

// 编辑键值对
final MutableEntry<String, Object> entry = copyOptions.editField(sFieldName, sValue);
if (null == entry) {
return;
}
sFieldName = entry.getKey();
// 对key做转换,转换后为null的跳过
if (null == sFieldName) {
return;
}
sValue = entry.getValue();

// 获取目标值真实类型并转换源值
final Type[] typeArguments = TypeKit.getTypeArguments(this.targetType);
if (null != typeArguments) {
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
sValue = copyOptions.editFieldValue(sFieldName, sValue);
}

// 目标赋值
Expand Down
Loading

0 comments on commit b1fec68

Please sign in to comment.