mirror of
https://gitee.com/dromara/hutool.git
synced 2025-10-07 07:04:40 +08:00
Compare commits
2 Commits
11b0abf7b3
...
8ef76cc56b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8ef76cc56b | ||
![]() |
73de40813f |
@@ -16,6 +16,7 @@
|
||||
|
||||
package cn.hutool.v7.core.lang.tuple;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ import java.util.Objects;
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class Triple<L, M, R> extends Pair<L, R> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -80,8 +82,7 @@ public class Triple<L, M, R> extends Pair<L, R> {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof Triple) {
|
||||
final Triple<?, ?, ?> triple = (Triple<?, ?, ?>) o;
|
||||
if (o instanceof Triple<?, ?, ?> triple) {
|
||||
return Objects.equals(getLeft(), triple.getLeft()) &&
|
||||
Objects.equals(getMiddle(), triple.getMiddle()) &&
|
||||
Objects.equals(getRight(), triple.getRight());
|
||||
|
@@ -19,6 +19,8 @@ package cn.hutool.v7.core.thread;
|
||||
import cn.hutool.v7.core.lang.builder.Builder;
|
||||
import cn.hutool.v7.core.util.ObjUtil;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
@@ -35,6 +37,7 @@ import java.util.concurrent.*;
|
||||
* @since 4.1.9
|
||||
*/
|
||||
public class ExecutorBuilder implements Builder<ThreadPoolExecutor> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -256,12 +259,9 @@ public class ExecutorBuilder implements Builder<ThreadPoolExecutor> {
|
||||
final int maxPoolSize = builder.maxPoolSize;
|
||||
final long keepAliveTime = builder.keepAliveTime;
|
||||
final BlockingQueue<Runnable> workQueue;
|
||||
if (null != builder.workQueue) {
|
||||
workQueue = builder.workQueue;
|
||||
} else {
|
||||
// corePoolSize为0则要使用SynchronousQueue避免无限阻塞
|
||||
workQueue = (corePoolSize <= 0) ? new SynchronousQueue<>() : new LinkedBlockingQueue<>(DEFAULT_QUEUE_CAPACITY);
|
||||
}
|
||||
// corePoolSize为0则要使用SynchronousQueue避免无限阻塞
|
||||
workQueue = Objects.requireNonNullElseGet(builder.workQueue,
|
||||
() -> (corePoolSize <= 0) ? new SynchronousQueue<>() : new LinkedBlockingQueue<>(DEFAULT_QUEUE_CAPACITY));
|
||||
final ThreadFactory threadFactory = (null != builder.threadFactory) ? builder.threadFactory : Executors.defaultThreadFactory();
|
||||
final RejectedExecutionHandler handler = ObjUtil.defaultIfNull(builder.handler, RejectPolicy.ABORT.getValue());
|
||||
|
||||
|
@@ -167,8 +167,7 @@ public class JSONObject extends MapWrapper<String, JSON> implements JSON, JSONGe
|
||||
return putValue(key, 1);
|
||||
}
|
||||
|
||||
if (json instanceof JSONPrimitive) {
|
||||
final JSONPrimitive jsonPrimitive = (JSONPrimitive) json;
|
||||
if (json instanceof JSONPrimitive jsonPrimitive) {
|
||||
if (jsonPrimitive.isNumber()) {
|
||||
jsonPrimitive.increment();
|
||||
return this;
|
||||
|
@@ -261,28 +261,28 @@ public class JSONParser {
|
||||
* @return JSONPrimitive或{@code null}
|
||||
*/
|
||||
private JSONPrimitive nextJSONPrimitive(final char firstChar) {
|
||||
switch (firstChar) {
|
||||
case CharUtil.DOUBLE_QUOTES:
|
||||
case CharUtil.SINGLE_QUOTE:
|
||||
return switch (firstChar) {
|
||||
case CharUtil.DOUBLE_QUOTES, CharUtil.SINGLE_QUOTE ->
|
||||
// 引号包围,表示字符串值
|
||||
return factory.ofPrimitive(tokener.nextWrapString(firstChar));
|
||||
case 't':
|
||||
case 'T':
|
||||
factory.ofPrimitive(tokener.nextWrapString(firstChar));
|
||||
case 't', 'T' -> {
|
||||
checkTrue(tokener.next(3));
|
||||
return factory.ofPrimitive(true);
|
||||
case 'f':
|
||||
case 'F':
|
||||
yield factory.ofPrimitive(true);
|
||||
}
|
||||
case 'f', 'F' -> {
|
||||
checkFalse(tokener.next(4));
|
||||
return factory.ofPrimitive(false);
|
||||
case 'n':
|
||||
case 'N':
|
||||
yield factory.ofPrimitive(false);
|
||||
}
|
||||
case 'n', 'N' -> {
|
||||
checkNull(tokener.next(3));
|
||||
return null;
|
||||
default:
|
||||
yield null;
|
||||
}
|
||||
default -> {
|
||||
final Object value = InternalJSONUtil.parseNumberOrString(tokener.nextUnwrapString(firstChar));
|
||||
// 非引号包围,可能为数字、null等
|
||||
return null == value ? null : factory.ofPrimitive(value);
|
||||
}
|
||||
yield null == value ? null : factory.ofPrimitive(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package cn.hutool.v7.json.xml;
|
||||
|
||||
import cn.hutool.v7.core.date.DateUtil;
|
||||
import cn.hutool.v7.json.JSONConfig;
|
||||
import cn.hutool.v7.json.JSONObject;
|
||||
import cn.hutool.v7.json.JSONUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IssueID0HP2Test {
|
||||
/**
|
||||
* JSON转换为XML时使用自定义格式<br>
|
||||
* putValue时就会把日期转为自定义格式的字符串,因此转XML是直接转换
|
||||
*/
|
||||
@Test
|
||||
void jsonWithDateToXmlTest() {
|
||||
final JSONObject json = JSONUtil.ofObj(JSONConfig.of().setDateFormat("yyyy/MM/dd"))
|
||||
.putValue("date", DateUtil.parse("2025-10-03"));
|
||||
|
||||
String xml = JSONUtil.toXmlStr(json);
|
||||
Assertions.assertEquals("<date>2025/10/03</date>", xml);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user