3 Commits

Author SHA1 Message Date
8ea49dd83b 新增 UnifiedResponses
Reviewed-on: http://zhouxy.xyz:3000/plusone/plusone-commons/pulls/23
2025-02-20 20:31:26 +08:00
0f7ab8fed5 1.0.0-RC3
Merge pull request '1.0.0-RC3' (#21) from 1.x.x into dev
2025-02-14 19:03:05 +08:00
0c4cfd3044 1.0.0-RC2
Reviewed-on: http://zhouxy.xyz:3000/plusone/plusone-commons/pulls/19
2025-01-07 17:18:48 +08:00
32 changed files with 48 additions and 59 deletions

12
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>xyz.zhouxy.plusone</groupId>
<artifactId>plusone-commons</artifactId>
<version>1.0.3</version>
<version>1.0.0-RC3</version>
<properties>
<!-- Basic properties -->
@@ -16,18 +16,18 @@
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Versions of compile dependencies -->
<guava.version>33.4.2-jre</guava.version>
<joda-time.version>2.14.0</joda-time.version>
<guava.version>33.4.0-jre</guava.version>
<joda-time.version>2.13.0</joda-time.version>
<!-- Versions of test dependencies -->
<commons-lang3.version>3.17.0</commons-lang3.version>
<logback.version>1.2.13</logback.version>
<junit.version>5.12.1</junit.version>
<junit.version>5.11.4</junit.version>
<lombok.version>1.18.36</lombok.version>
<hutool.version>5.8.37</hutool.version>
<hutool.version>5.8.35</hutool.version>
<mybatis.version>3.5.19</mybatis.version>
<h2.version>2.2.224</h2.version>
<jackson.version>2.18.3</jackson.version>
<jackson.version>2.18.2</jackson.version>
<gson.version>2.12.1</gson.version>
</properties>

View File

@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
* 标识方法是读方法,如 getter。
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 1.0
* @see WriterMethod
*/
@Target(ElementType.METHOD)

View File

@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
* <p>标识方法为静态工厂方法
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)

View File

@@ -29,7 +29,7 @@ import java.lang.annotation.Documented;
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @version 1.0
* @since 1.0.0
* @since 1.0
* @see UnsupportedOperationException
*/
@Documented

View File

@@ -26,7 +26,7 @@ import java.lang.annotation.Target;
* ValueObject - 值对象
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
@Inherited
@Target(ElementType.TYPE)

View File

@@ -26,7 +26,7 @@ import java.lang.annotation.Target;
* <p>该注解用于提醒、强调父类虽然有默认实现,但子类可以根据自己的需要覆写。</p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)

View File

@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
* 标识方法是写方法,如 setter。
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 1.0
* @see ReaderMethod
*/
@Target(ElementType.METHOD)

View File

@@ -34,7 +34,7 @@ import com.google.common.collect.Table;
* 集合工具类
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class CollectionTools {

View File

@@ -20,7 +20,7 @@ package xyz.zhouxy.plusone.commons.exception;
* 数据不存在异常
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public final class DataNotExistsException extends Exception {

View File

@@ -36,7 +36,7 @@ import xyz.zhouxy.plusone.commons.exception.MultiTypesException.ExceptionType;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public final class ParsingFailureException
extends RuntimeException

View File

@@ -27,7 +27,7 @@ package xyz.zhouxy.plusone.commons.exception.business;
* <b>NOTE: 通常表示业务中的意外情况。如:用户错误输入、缺失必填字段、用户余额不足等。</b>
* </p>
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class BizException extends RuntimeException {

View File

@@ -32,7 +32,7 @@ import xyz.zhouxy.plusone.commons.exception.MultiTypesException;
* <b>NOTE: 属业务异常</b>
* </p>
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public final class InvalidInputException
extends RequestParamsException

View File

@@ -24,7 +24,7 @@ package xyz.zhouxy.plusone.commons.exception.business;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class RequestParamsException extends BizException {

View File

@@ -29,7 +29,7 @@ package xyz.zhouxy.plusone.commons.exception.system;
* 后续需要排查原因。
* </p>
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public final class DataOperationResultException extends SysException {

View File

@@ -24,7 +24,7 @@ package xyz.zhouxy.plusone.commons.exception.system;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class NoAvailableMacFoundException extends SysException {
private static final long serialVersionUID = 152827098461071551L;

View File

@@ -24,7 +24,7 @@ package xyz.zhouxy.plusone.commons.exception.system;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class SysException extends RuntimeException {

View File

@@ -24,9 +24,9 @@ import java.util.function.Supplier;
*
* <p>
* 返回 {@code Optional&lt;T&gt;} 对象。
*
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
* @see Optional
* @see Supplier
*/

View File

@@ -19,14 +19,14 @@ package xyz.zhouxy.plusone.commons.function;
import java.util.function.Predicate;
/**
* PredicateTools
* Predicates
*
* <p>
* {@link Predicate} 相关操作。
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
* @see Predicate
*/
public class PredicateTools {
@@ -36,12 +36,12 @@ public class PredicateTools {
* 如将 {@code Objects::nonNull} 明确地指定为 {@code Predicate&lt;String&gt;}
* 使之可以链式调用 {@link Predicate#and(Predicate)}、{@link Predicate#or(Predicate)}
* 等方法,连接其它 {@code Predicate<? super T>} 对象。
*
*
* <pre>
* Predicate&lt;String&gt; predicate = PredicateTools.&lt;String&gt;from(Objects::nonNull)
* .and(StringUtils::isNotEmpty);
* </pre>
*
*
* @param <T> 目标类型
* @param predicate Lambda 表达式
* @return 传入的表达式自动成为 {@link Predicate} 实例

View File

@@ -16,7 +16,6 @@
package xyz.zhouxy.plusone.commons.function;
@FunctionalInterface
public interface ThrowingPredicate<T, E extends Throwable> {
/**

View File

@@ -26,7 +26,7 @@ import java.util.function.BiFunction;
* 接受类型为 T 和 U 的两个参数,返回 {@code Optional&lt;R&gt;} 对象。
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
* @see Optional
* @see BiFunction
*/

View File

@@ -26,7 +26,7 @@ import java.util.function.Function;
* 接受类型为 T 的参数,返回 {@code Optional&lt;R&gt;} 对象。
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
* @see Optional
* @see Function
*/

View File

@@ -39,7 +39,7 @@ import xyz.zhouxy.plusone.commons.util.StringTools;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 1.0
* @see xyz.zhouxy.plusone.commons.constant.PatternConsts#CHINESE_2ND_ID_CARD_NUMBER
*/
@ValueObject

View File

@@ -30,7 +30,7 @@ import xyz.zhouxy.plusone.commons.util.AssertTools;
* 带校验的字符串值对象
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public abstract class ValidatableStringRecord<T extends ValidatableStringRecord<T>>
implements Comparable<T> {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2025 the original author or authors.
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -37,7 +37,7 @@ import javax.annotation.Nullable;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class ArrayTools {

View File

@@ -31,7 +31,7 @@ import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod;
* </p>
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
*/
public class BigDecimals {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023-2025 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -184,7 +184,7 @@ public class DateTimeTools {
/**
* 使用指定时区,将 {@link LocalDateTime} 对象转换为 {@link Instant} 对象
*
* @param localDateTime {@link LocalDateTime} 对象
* @param LocalDateTime {@link LocalDateTime} 对象
* @param zone 时区
* @return {@link Instant} 对象
*/

View File

@@ -42,6 +42,7 @@ import xyz.zhouxy.plusone.commons.exception.system.NoAvailableMacFoundException;
* <li><a href="https://juejin.cn/post/7265516484029743138">关于若干读者,阅读“改良版雪花算法”后提出的几个共性问题的回复。</a></li>
* </ul>
* </p>
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
*/
public class IdWorker {

View File

@@ -26,13 +26,13 @@ import javax.annotation.Nullable;
import com.google.common.annotations.Beta;
/**
* OptionalTools
* OptionalUtil
*
* <p>
* 提供一些 Optional 相关的方法
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 0.1.0
* @see Optional
* @see OptionalInt
* @see OptionalLong

View File

@@ -31,7 +31,7 @@ import javax.annotation.Nullable;
* TreeBuilder
*
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
* @since 1.0.0
* @since 1.0
*/
public class TreeBuilder<T, TSubTree extends T, TIdentity> {
private final Function<T, TIdentity> identityGetter;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2025 the original author or authors.
* Copyright 2024-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2024-2025 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -184,34 +184,24 @@ public class PagingAndSortingQueryParamsTests {
assertThrows(IllegalArgumentException.class, () -> queryParams.buildPagingParams()); // NOSONAR
}
static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Test
void testGson() {
void testGson() throws Exception {
Gson gson = new GsonBuilder()
.registerTypeAdapter(LocalDate.class, new TypeAdapter<LocalDate>() {
@Override
public void write(JsonWriter out, LocalDate value) throws IOException {
out.value(DateTimeFormatter.ISO_DATE.format(value));
out.value(dateFormatter.format(value));
}
@Override
public LocalDate read(JsonReader in) throws IOException {
return LocalDate.parse(in.nextString(), DateTimeFormatter.ISO_DATE);
return LocalDate.parse(in.nextString(), dateFormatter);
}
})
.registerTypeAdapter(LocalDateTime.class, new TypeAdapter<LocalDateTime>() {
@Override
public void write(JsonWriter out, LocalDateTime value) throws IOException {
out.value(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value));
}
@Override
public LocalDateTime read(JsonReader in) throws IOException {
return LocalDateTime.parse(in.nextString(), DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
})
.create();
try (SqlSession session = sqlSessionFactory.openSession()) {
AccountQueryParams params = gson.fromJson(JSON_STR, AccountQueryParams.class);
@@ -222,7 +212,6 @@ public class PagingAndSortingQueryParamsTests {
List<AccountVO> list = accountQueries.queryAccountList(params, pagingParams);
long count = accountQueries.countAccount(params);
PageResult<AccountVO> accountPageResult = PageResult.of(list, count);
log.info(gson.toJson(accountPageResult));
assertEquals(Lists.newArrayList(
@@ -237,7 +226,7 @@ public class PagingAndSortingQueryParamsTests {
}
AccountQueryParams queryParams = gson.fromJson(WRONG_JSON_STR, AccountQueryParams.class);
assertThrows(IllegalArgumentException.class, queryParams::buildPagingParams);
assertThrows(IllegalArgumentException.class, () -> queryParams.buildPagingParams()); // NOSONAR
}
}