generated from mingliqiye/lib-tem
no message
All checks were successful
Gitea Actions Build / Build (push) Successful in 59s
All checks were successful
Gitea Actions Build / Build (push) Successful in 59s
This commit is contained in:
parent
49c3b76250
commit
0376ef3a9d
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils
|
||||
* CurrentFile build.gradle.kts
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
@ -65,6 +87,18 @@ tasks.withType<org.gradle.jvm.tasks.Jar> {
|
||||
manifest {
|
||||
attributes(
|
||||
mapOf(
|
||||
"Main-Class" to "com.mingliqiye.utils.Main",
|
||||
"Specification-Title" to ARTIFACTID,
|
||||
"Specification-Version" to VERSIONS,
|
||||
"Specification-Vendor" to "minglipro",
|
||||
"Specification-Build-Time" to LocalDateTime.now()
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS")),
|
||||
"Specification-Package" to GROUPSID,
|
||||
"Specification-Build-Number" to "1",
|
||||
"Specification-Build-OS" to System.getProperty("os.name"),
|
||||
"Specification-Build-Java" to System.getProperty("java.version"),
|
||||
"Specification-Build-Java-Vendor" to System.getProperty("java.vendor"),
|
||||
"Specification-Build-Java-Vendor-URL" to System.getProperty("java.vendor.url"),
|
||||
"Implementation-Title" to ARTIFACTID,
|
||||
"Implementation-Version" to VERSIONS,
|
||||
"Implementation-Package" to GROUPSID,
|
||||
|
||||
@ -1,4 +1,25 @@
|
||||
#
|
||||
# Copyright 2025 mingliqiye
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# ProjectName mingli-utils
|
||||
# ModuleName mingli-utils
|
||||
# CurrentFile gradle.properties
|
||||
# LastUpdate 2025-09-09 09:34:12
|
||||
# UpdateUser MingLiPro
|
||||
#
|
||||
JDKVERSIONS=1.8
|
||||
GROUPSID=com.mingliqiye.utils
|
||||
ARTIFACTID=mingli-utils
|
||||
VERSIONS=2.0.4
|
||||
VERSIONS=3.0.1
|
||||
|
||||
21
gradle/wrapper/gradle-wrapper.properties
vendored
21
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,3 +1,24 @@
|
||||
#
|
||||
# Copyright 2025 mingliqiye
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# ProjectName mingli-utils
|
||||
# ModuleName mingli-utils
|
||||
# CurrentFile gradle-wrapper.properties
|
||||
# LastUpdate 2025-09-09 08:37:34
|
||||
# UpdateUser MingLiPro
|
||||
#
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-1-bin.zip
|
||||
|
||||
10
gradlew
vendored
10
gradlew
vendored
@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
# Copyright 2025 mingliqiye
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -15,7 +15,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# ProjectName mingli-utils
|
||||
# ModuleName mingli-utils
|
||||
# CurrentFile gradlew
|
||||
# LastUpdate 2025-09-09 08:37:33
|
||||
# UpdateUser MingLiPro
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
|
||||
@ -1 +1,23 @@
|
||||
#
|
||||
# Copyright 2025 mingliqiye
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# ProjectName mingli-utils
|
||||
# ModuleName mingli-utils.main
|
||||
# CurrentFile org.springframework.boot.autoconfigure.AutoConfiguration.imports
|
||||
# LastUpdate 2025-09-09 08:37:33
|
||||
# UpdateUser MingLiPro
|
||||
#
|
||||
|
||||
com.mingliqiye.utils.springboot.autoconfigure.AutoConfiguration
|
||||
|
||||
@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils
|
||||
* CurrentFile settings.gradle.kts
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
val ARTIFACTID: String by settings.extra
|
||||
val VERSIONS: String by settings.extra
|
||||
rootProject.name = "$ARTIFACTID $VERSIONS"
|
||||
rootProject.name = ARTIFACTID
|
||||
|
||||
@ -1,52 +1,33 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Main.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils;
|
||||
|
||||
import com.mingliqiye.utils.collection.Lists;
|
||||
import com.mingliqiye.utils.string.StringUtil;
|
||||
import com.mingliqiye.utils.time.DateTime;
|
||||
import com.mingliqiye.utils.time.Formatter;
|
||||
import java.util.List;
|
||||
import com.mingliqiye.utils.springboot.autoconfigure.AutoConfiguration;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 字符串工具使用示例
|
||||
System.out.println("=== 字符串工具使用示例 ===");
|
||||
String formatted = StringUtil.format(
|
||||
"你好 {},今天是{}年{}月{}日",
|
||||
"张三",
|
||||
2025,
|
||||
7,
|
||||
25
|
||||
);
|
||||
System.out.println(formatted);
|
||||
|
||||
List<String> fruits = Lists.newArrayList("苹果", "香蕉", "橙子");
|
||||
String joined = StringUtil.join(", ", fruits);
|
||||
System.out.println("水果列表: " + joined);
|
||||
|
||||
// 时间工具使用示例
|
||||
System.out.println("\n=== 时间工具使用示例 ===");
|
||||
DateTime now = DateTime.now();
|
||||
System.out.println("当前时间: " + now);
|
||||
System.out.println(
|
||||
"标准格式: " + now.format(Formatter.STANDARD_DATETIME)
|
||||
);
|
||||
|
||||
DateTime specificDate = DateTime.of(2025, 1, 1, 12, 0, 0);
|
||||
System.out.println(
|
||||
"指定时间: " + specificDate.format(Formatter.STANDARD_DATETIME)
|
||||
);
|
||||
|
||||
// 集合工具使用示例
|
||||
System.out.println("\n=== 集合工具使用示例 ===");
|
||||
List<Integer> numbers = Lists.newArrayList(10, 20, 30);
|
||||
System.out.println("数字列表: " + numbers);
|
||||
|
||||
List<String> linkedList = Lists.newLinkedList(
|
||||
"第一个",
|
||||
"第二个",
|
||||
"第三个"
|
||||
);
|
||||
System.out.println("链表内容: " + linkedList);
|
||||
public static void main(String[] args) throws IOException {
|
||||
AutoConfiguration.printBanner();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile AesUtils.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.aes;
|
||||
|
||||
import com.mingliqiye.utils.base64.Base64Utils;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base64Utils.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base64;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Factory.java
|
||||
* LastUpdate 2025-09-09 08:39:07
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.bean;
|
||||
|
||||
import com.mingliqiye.utils.bean.annotation.ComponentBean;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile ComponentBean.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.bean.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile InjectBean.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.bean.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile SpringBeanUtil.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.bean.springboot;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile ByteUtil.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.bytes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
39
src/com/mingliqiye/utils/callback/P10Function.java
Normal file
39
src/com/mingliqiye/utils/callback/P10Function.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P10Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P10Function<P, P1, P2, P3, P4, P5, P6, P7, P8, P9> {
|
||||
void call(
|
||||
P p,
|
||||
P1 p1,
|
||||
P2 p2,
|
||||
P3 p3,
|
||||
P4 p4,
|
||||
P5 p5,
|
||||
P6 p6,
|
||||
P7 p7,
|
||||
P8 p8,
|
||||
P9 p9
|
||||
);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P10RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P10RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P10RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P10RFunction<P, P1, P2, P3, P4, P5, P6, P7, P8, P9, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P1Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P1Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P1Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P1Function<P> {
|
||||
void call(P p);
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
/**
|
||||
* PRFunction接口表示一个接收参数P并返回结果R的函数式接口
|
||||
* <p>
|
||||
* 该接口使用@,表明它是一个函数式接口,
|
||||
* 只包含一个抽象方法FunctionalInterface注解标记call,可用于Lambda表达式和方法引用
|
||||
* </p>
|
||||
*
|
||||
* @author MingLiPro
|
||||
* @param <P> 函数接收的参数类型
|
||||
* @param <R> 函数返回的结果类型
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface P1R1Function<P, R> {
|
||||
/**
|
||||
* 执行函数调用
|
||||
*
|
||||
* @param p 输入参数
|
||||
* @return 函数执行结果
|
||||
*/
|
||||
R call(P p);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P1RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P1RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P1RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P1RFunction<P, R> {
|
||||
R call(P p);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P2Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P2Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P2Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P2Function<P, P1> {
|
||||
void call(P p, P1 p1);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P2RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P2RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P2RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P2RFunction<P, P1, R> {
|
||||
R call(P p, P1 p1);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P3Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P3Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P3Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P3Function<P, P1, P2> {
|
||||
void call(P p, P1 p1, P2 p2);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P3RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P3RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P3RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P3RFunction<P, P1, P2, R> {
|
||||
R call(P p, P1 p1, P2 p2);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P4Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P4Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P4Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P4Function<P, P1, P2, P3> {
|
||||
void call(P p, P1 p1, P2 p2, P3 p3);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P4RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P4RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P4RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P4RFunction<P, P1, P2, P3, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P5Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P5Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P5Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P5Function<P, P1, P2, P3, P4> {
|
||||
void call(P p, P1 p1, P2 p2, P3 p3, P4 p4);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P5RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P5RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P5RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P5RFunction<P, P1, P2, P3, P4, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3, P4 p4);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P6Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P6Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P6Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P6Function<P, P1, P2, P3, P4, P5> {
|
||||
void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P6RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P6RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P6RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P6RFunction<P, P1, P2, P3, P4, P5, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P7Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P7Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P7Function.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P7Function<P, P1, P2, P3, P4, P5, P6> {
|
||||
void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P7RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P7RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P7RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P7RFunction<P, P1, P2, P3, P4, P5, P6, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P8Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P8Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P8Function.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P8Function<P, P1, P2, P3, P4, P5, P6, P7> {
|
||||
void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P8RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P8RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P8RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P8RFunction<P, P1, P2, P3, P4, P5, P6, P7, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P9Function.java
Normal file
28
src/com/mingliqiye/utils/callback/P9Function.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P9Function.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P9Function<P, P1, P2, P3, P4, P5, P6, P7, P8> {
|
||||
void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8);
|
||||
}
|
||||
28
src/com/mingliqiye/utils/callback/P9RFunction.java
Normal file
28
src/com/mingliqiye/utils/callback/P9RFunction.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile P9RFunction.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.callback;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface P9RFunction<P, P1, P2, P3, P4, P5, P6, P7, P8, R> {
|
||||
R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8);
|
||||
}
|
||||
80
src/com/mingliqiye/utils/clone/CloneUtil.java
Normal file
80
src/com/mingliqiye/utils/clone/CloneUtil.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile CloneUtil.java
|
||||
* LastUpdate 2025-09-09 09:32:17
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.clone;
|
||||
|
||||
import com.mingliqiye.utils.json.JsonApi;
|
||||
import com.mingliqiye.utils.json.JsonException;
|
||||
import java.io.*;
|
||||
|
||||
public class CloneUtil {
|
||||
|
||||
/**
|
||||
* 对指定的可序列化对象进行深拷贝
|
||||
*
|
||||
* @param object 需要进行深拷贝的对象,必须实现Serializable接口
|
||||
* @param <T> 对象的类型,必须实现Serializable接口
|
||||
* @return 深拷贝后的新对象,与原对象内容相同但内存地址不同
|
||||
* @throws RuntimeException 当序列化或反序列化过程中发生IO异常或类未找到异常时抛出
|
||||
*/
|
||||
public static <T extends Serializable> T deepClone(T object) {
|
||||
try {
|
||||
ByteArrayOutputStream bao = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bao);
|
||||
oos.writeObject(object);
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(
|
||||
bao.toByteArray()
|
||||
);
|
||||
ObjectInputStream ois = new ObjectInputStream(bis);
|
||||
return (T) ois.readObject();
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 深度克隆对象,使用JSON序列化和反序列化实现
|
||||
*
|
||||
* @param <T> 对象类型参数
|
||||
* @param object 需要克隆的对象实例
|
||||
* @param jsonApi JSON序列化接口实现
|
||||
* @return 克隆后的对象实例
|
||||
*/
|
||||
public static <T> T deepJsonClone(T object, JsonApi jsonApi) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (jsonApi == null) {
|
||||
throw new IllegalArgumentException("jsonApi cannot be null");
|
||||
}
|
||||
|
||||
try {
|
||||
return (T) jsonApi.convert(object, object.getClass());
|
||||
} catch (Exception e) {
|
||||
throw new JsonException(
|
||||
"Failed to deep clone object using JSON",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Collection.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.collection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile ForEach.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.collection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -1,10 +1,31 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Lists.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.collection;
|
||||
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Lists工具类提供了一系列创建List实现的便捷方法。
|
||||
*
|
||||
|
||||
@ -1,9 +1,30 @@
|
||||
package com.mingliqiye.utils.collection;
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Maps.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
import lombok.var;
|
||||
package com.mingliqiye.utils.collection;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.var;
|
||||
|
||||
/**
|
||||
* Maps工具类提供了一系列创建Map实现的便捷方法。
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Sets.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.collection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile IsChanged.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.concurrent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile ThreadLocalDataHolder.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.data;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile FileUtil.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.file;
|
||||
|
||||
import com.mingliqiye.utils.string.StringUtil;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Debouncer.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.functions;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile HashUtils.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.hash;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Response.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.http;
|
||||
|
||||
import com.mingliqiye.utils.time.DateTime;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Serializers.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.jackson;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile FieldStructure.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.jna;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile WinKernel32.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.jna.time;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
|
||||
313
src/com/mingliqiye/utils/json/JacksonJsonApi.java
Normal file
313
src/com/mingliqiye/utils/json/JacksonJsonApi.java
Normal file
@ -0,0 +1,313 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JacksonJsonApi.java
|
||||
* LastUpdate 2025-09-09 09:31:31
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基于Jackson的JSON处理实现类,提供JSON字符串解析、格式化、合并、节点操作等功能。
|
||||
*/
|
||||
public class JacksonJsonApi implements JsonApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* 使用默认的ObjectMapper构造实例
|
||||
*/
|
||||
public JacksonJsonApi() {
|
||||
this.objectMapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定的ObjectMapper构造实例
|
||||
*
|
||||
* @param objectMapper 自定义的ObjectMapper实例
|
||||
*/
|
||||
public JacksonJsonApi(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定类型的对象
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param clazz 目标对象类型
|
||||
* @param <T> 泛型参数,表示目标对象类型
|
||||
* @return 解析后的对象
|
||||
* @throws JsonException 当解析失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public <T> T parse(String json, Class<T> clazz) {
|
||||
try {
|
||||
return objectMapper.readValue(json, clazz);
|
||||
} catch (IOException e) {
|
||||
throw new JsonException("Failed to parse JSON string", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为复杂泛型结构的对象(如List、Map等)
|
||||
*
|
||||
* @param json JSON字符串
|
||||
* @param type 泛型类型引用
|
||||
* @param <T> 泛型参数,表示目标对象类型
|
||||
* @return 解析后的对象
|
||||
* @throws JsonException 当解析失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public <T> T parse(String json, JsonTypeReference<T> type) {
|
||||
try {
|
||||
ObjectReader reader = objectMapper.readerFor(
|
||||
objectMapper.constructType(type.getType())
|
||||
);
|
||||
return reader.readValue(json);
|
||||
} catch (IOException e) {
|
||||
throw new JsonException("Failed to parse JSON string", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象格式化为JSON字符串
|
||||
*
|
||||
* @param object 待格式化的对象
|
||||
* @return 格式化后的JSON字符串
|
||||
* @throws JsonException 当格式化失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public String format(Object object) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JsonException(
|
||||
"Failed to format object to JSON string",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象格式化为美化(带缩进)的JSON字符串
|
||||
*
|
||||
* @param object 待格式化的对象
|
||||
* @return 美化后的JSON字符串
|
||||
* @throws JsonException 当格式化失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public String formatPretty(Object object) {
|
||||
try {
|
||||
return objectMapper
|
||||
.writerWithDefaultPrettyPrinter()
|
||||
.writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JsonException(
|
||||
"Failed to format object to pretty JSON string",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定元素类型的List
|
||||
*
|
||||
* @param json JSON字符串
|
||||
* @param elementType List中元素的类型
|
||||
* @param <T> 泛型参数,表示List中元素的类型
|
||||
* @return 解析后的List对象
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> parseList(String json, Class<T> elementType) {
|
||||
return parse(json, JsonTypeUtils.listType(elementType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定键值类型的Map
|
||||
*
|
||||
* @param json JSON字符串
|
||||
* @param keyType Map中键的类型
|
||||
* @param valueType Map中值的类型
|
||||
* @param <K> 泛型参数,表示Map中键的类型
|
||||
* @param <V> 泛型参数,表示Map中值的类型
|
||||
* @return 解析后的Map对象
|
||||
*/
|
||||
@Override
|
||||
public <K, V> Map<K, V> parseMap(
|
||||
String json,
|
||||
Class<K> keyType,
|
||||
Class<V> valueType
|
||||
) {
|
||||
return parse(json, JsonTypeUtils.MapType(keyType, valueType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断给定字符串是否是有效的JSON格式
|
||||
*
|
||||
* @param json 待验证的字符串
|
||||
* @return 如果是有效JSON返回true,否则返回false
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidJson(String json) {
|
||||
try {
|
||||
objectMapper.readTree(json);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并多个JSON字符串为一个JSON对象
|
||||
*
|
||||
* @param jsons 多个JSON字符串
|
||||
* @return 合并后的JSON字符串
|
||||
* @throws JsonException 当合并失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public String merge(String... jsons) {
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
for (String json : jsons) {
|
||||
try {
|
||||
JsonNode node = objectMapper.readTree(json);
|
||||
if (node.isObject()) {
|
||||
result.setAll((ObjectNode) node);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// 忽略无效的JSON字符串
|
||||
}
|
||||
}
|
||||
try {
|
||||
return objectMapper.writeValueAsString(result);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JsonException("Failed to merge JSON strings", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JSON字符串中指定路径的节点值
|
||||
*
|
||||
* @param json JSON字符串
|
||||
* @param path 节点路径,使用"."分隔
|
||||
* @return 节点值的文本表示,如果路径不存在则返回null
|
||||
* @throws JsonException 当获取节点值失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public String getNodeValue(String json, String path) {
|
||||
try {
|
||||
JsonNode node = objectMapper.readTree(json);
|
||||
String[] paths = path.split("\\.");
|
||||
for (String p : paths) {
|
||||
node = node.get(p);
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return node.asText();
|
||||
} catch (IOException e) {
|
||||
throw new JsonException("Failed to get node value", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新JSON字符串中指定路径的节点值
|
||||
*
|
||||
* @param json JSON字符串
|
||||
* @param path 节点路径,使用"."分隔
|
||||
* @param newValue 新的节点值
|
||||
* @return 更新后的JSON字符串
|
||||
* @throws JsonException 当更新节点值失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
public String updateNodeValue(String json, String path, Object newValue) {
|
||||
try {
|
||||
JsonNode node = objectMapper.readTree(json);
|
||||
if (node instanceof ObjectNode) {
|
||||
ObjectNode objectNode = (ObjectNode) node;
|
||||
String[] paths = path.split("\\.");
|
||||
JsonNode current = objectNode;
|
||||
|
||||
// 导航到目标节点的父节点
|
||||
for (int i = 0; i < paths.length - 1; i++) {
|
||||
current = current.get(paths[i]);
|
||||
if (current == null || !(current instanceof ObjectNode)) {
|
||||
return json; // 路径不存在或无效
|
||||
}
|
||||
}
|
||||
|
||||
// 更新值
|
||||
if (current instanceof ObjectNode) {
|
||||
ObjectNode parent = (ObjectNode) current;
|
||||
if (newValue == null) {
|
||||
parent.remove(paths[paths.length - 1]);
|
||||
} else {
|
||||
parent.set(
|
||||
paths[paths.length - 1],
|
||||
objectMapper.valueToTree(newValue)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return objectMapper.writeValueAsString(objectNode);
|
||||
}
|
||||
return json;
|
||||
} catch (IOException e) {
|
||||
throw new JsonException("Failed to update node value", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在不同对象类型之间进行转换
|
||||
*
|
||||
* @param source 源对象
|
||||
* @param destinationClass 目标对象类型
|
||||
* @param <T> 源对象类型
|
||||
* @param <D> 目标对象类型
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
@Override
|
||||
public <T, D> D convert(T source, Class<D> destinationClass) {
|
||||
return objectMapper.convertValue(source, destinationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在不同泛型对象类型之间进行转换
|
||||
*
|
||||
* @param source 源对象
|
||||
* @param destinationType 目标对象的泛型类型引用
|
||||
* @param <T> 源对象类型
|
||||
* @param <D> 目标对象类型
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
@Override
|
||||
public <T, D> D convert(T source, JsonTypeReference<D> destinationType) {
|
||||
return objectMapper.convertValue(
|
||||
source,
|
||||
objectMapper.constructType(destinationType.getType())
|
||||
);
|
||||
}
|
||||
}
|
||||
220
src/com/mingliqiye/utils/json/JsonApi.java
Normal file
220
src/com/mingliqiye/utils/json/JsonApi.java
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JsonApi.java
|
||||
* LastUpdate 2025-09-09 09:22:02
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.json;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* JSON处理接口,提供JSON字符串与Java对象之间的相互转换功能
|
||||
*/
|
||||
public interface JsonApi {
|
||||
/**
|
||||
* 将JSON字符串解析为指定类型的对象
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param clazz 目标对象的Class类型
|
||||
* @param <T> 泛型参数,表示目标对象的类型
|
||||
* @return 解析后的对象实例
|
||||
*/
|
||||
<T> T parse(String json, Class<T> clazz);
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定泛型类型对象
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param type 目标对象的Type类型(支持泛型)
|
||||
* @param <T> 泛型参数,表示目标对象的类型
|
||||
* @return 解析后的对象实例
|
||||
*/
|
||||
<T> T parse(String json, JsonTypeReference<T> type);
|
||||
|
||||
/**
|
||||
* 将对象格式化为JSON字符串
|
||||
*
|
||||
* @param object 待格式化的对象
|
||||
* @return 格式化后的JSON字符串
|
||||
*/
|
||||
String format(Object object);
|
||||
|
||||
/**
|
||||
* 将字节数组形式的JSON解析为指定类型的对象
|
||||
*
|
||||
* @param json 待解析的JSON字节数组
|
||||
* @param clazz 目标对象的Class类型
|
||||
* @param <T> 泛型参数,表示目标对象的类型
|
||||
* @return 解析后的对象实例
|
||||
*/
|
||||
default <T> T parse(byte[] json, Class<T> clazz) {
|
||||
return parse(new String(json), clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节数组形式的JSON解析为指定泛型类型对象
|
||||
*
|
||||
* @param json 待解析的JSON字节数组
|
||||
* @param type 目标对象的Type类型(支持泛型)
|
||||
* @param <T> 泛型参数,表示目标对象的类型
|
||||
* @return 解析后的对象实例
|
||||
*/
|
||||
default <T> T parse(byte[] json, JsonTypeReference<T> type) {
|
||||
return parse(new String(json), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定类型的对象,解析失败时返回默认值
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param clazz 目标对象的Class类型
|
||||
* @param defaultValue 解析失败时返回的默认值
|
||||
* @param <T> 泛型参数,表示目标对象的类型
|
||||
* @return 解析后的对象实例或默认值
|
||||
*/
|
||||
default <T> T parse(String json, Class<T> clazz, T defaultValue) {
|
||||
try {
|
||||
return parse(json, clazz);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定泛型类型对象,解析失败时返回默认值
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param type 目标对象的Type类型(支持泛型)
|
||||
* @param defaultValue 解析失败时返回的默认值
|
||||
* @param <T> 泛型参数,表示目标对象的类型
|
||||
* @return 解析后的对象实例或默认值
|
||||
*/
|
||||
default <T> T parse(
|
||||
String json,
|
||||
JsonTypeReference<T> type,
|
||||
T defaultValue
|
||||
) {
|
||||
try {
|
||||
return parse(json, type);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象格式化为美化格式的JSON字符串(带缩进和换行)
|
||||
*
|
||||
* @param object 待格式化的对象
|
||||
* @return 格式化后的美化JSON字符串
|
||||
*/
|
||||
String formatPretty(Object object);
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定元素类型的List集合
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param elementType List中元素的类型
|
||||
* @param <T> 泛型参数,表示List中元素的类型
|
||||
* @return 解析后的List集合
|
||||
*/
|
||||
default <T> List<T> parseList(String json, Class<T> elementType) {
|
||||
return parse(json, JsonTypeUtils.listType(elementType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON字符串解析为指定键值类型的Map集合
|
||||
*
|
||||
* @param json 待解析的JSON字符串
|
||||
* @param keyType Map中键的类型
|
||||
* @param valueType Map中值的类型
|
||||
* @param <K> 泛型参数,表示Map中键的类型
|
||||
* @param <V> 泛型参数,表示Map中值的类型
|
||||
* @return 解析后的Map集合
|
||||
*/
|
||||
default <K, V> Map<K, V> parseMap(
|
||||
String json,
|
||||
Class<K> keyType,
|
||||
Class<V> valueType
|
||||
) {
|
||||
JsonTypeReference<Map<K, V>> mapType = new JsonTypeReference<
|
||||
Map<K, V>
|
||||
>() {};
|
||||
return parse(json, mapType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证字符串是否为有效的JSON格式
|
||||
*
|
||||
* @param json 待验证的字符串
|
||||
* @return 如果是有效的JSON格式返回true,否则返回false
|
||||
*/
|
||||
boolean isValidJson(String json);
|
||||
|
||||
/**
|
||||
* 将对象转换为JSON字节数组
|
||||
*
|
||||
* @param object 待转换的对象
|
||||
* @return 转换后的JSON字节数组
|
||||
*/
|
||||
default byte[] toBytes(Object object) {
|
||||
return format(object).getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转换为美化格式的JSON字节数组
|
||||
*
|
||||
* @param object 待转换的对象
|
||||
* @return 转换后的美化格式JSON字节数组
|
||||
*/
|
||||
default byte[] toBytesPretty(Object object) {
|
||||
return formatPretty(object).getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并多个JSON字符串为一个JSON对象
|
||||
*
|
||||
* @param jsons 待合并的JSON字符串数组
|
||||
* @return 合并后的JSON字符串
|
||||
*/
|
||||
String merge(String... jsons);
|
||||
|
||||
/**
|
||||
* 获取JSON字符串中指定路径节点的值
|
||||
*
|
||||
* @param json JSON字符串
|
||||
* @param path 节点路径(如:"user.name")
|
||||
* @return 节点值的字符串表示
|
||||
*/
|
||||
String getNodeValue(String json, String path);
|
||||
|
||||
/**
|
||||
* 更新JSON字符串中指定路径节点的值
|
||||
*
|
||||
* @param json 原始JSON字符串
|
||||
* @param path 节点路径(如:"user.name")
|
||||
* @param newValue 新的节点值
|
||||
* @return 更新后的JSON字符串
|
||||
*/
|
||||
String updateNodeValue(String json, String path, Object newValue);
|
||||
|
||||
<T, D> D convert(T source, Class<D> destinationClass);
|
||||
<T, D> D convert(T source, JsonTypeReference<D> destinationType);
|
||||
}
|
||||
34
src/com/mingliqiye/utils/json/JsonException.java
Normal file
34
src/com/mingliqiye/utils/json/JsonException.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JsonException.java
|
||||
* LastUpdate 2025-09-09 09:25:08
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.json;
|
||||
|
||||
public class JsonException extends RuntimeException {
|
||||
|
||||
public JsonException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public JsonException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
175
src/com/mingliqiye/utils/json/JsonTypeReference.java
Normal file
175
src/com/mingliqiye/utils/json/JsonTypeReference.java
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JsonTypeReference.java
|
||||
* LastUpdate 2025-09-09 09:20:05
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.json;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 通用的 JSON 类型引用类,用于在运行时保留泛型类型信息
|
||||
* 适用于所有 JSON 库(Jackson、Gson、Fastjson 等)
|
||||
*
|
||||
* @param <T> 引用的泛型类型
|
||||
*/
|
||||
@Getter
|
||||
public abstract class JsonTypeReference<T>
|
||||
implements Comparable<JsonTypeReference<T>> {
|
||||
|
||||
protected final Type type;
|
||||
|
||||
/**
|
||||
* 构造函数,通过反射获取泛型类型信息
|
||||
* 仅供内部匿名子类使用
|
||||
*/
|
||||
protected JsonTypeReference() {
|
||||
Type superClass = getClass().getGenericSuperclass();
|
||||
|
||||
// 检查是否为匿名子类,防止直接实例化导致无法获取泛型信息
|
||||
if (superClass instanceof Class) {
|
||||
throw new IllegalArgumentException(
|
||||
"必须使用匿名子类方式创建 JsonTypeReference," +
|
||||
"例如: new JsonTypeReference<List<String>>() {}"
|
||||
);
|
||||
}
|
||||
|
||||
this.type =
|
||||
((ParameterizedType) superClass).getActualTypeArguments()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数,直接指定类型
|
||||
* @param type 具体的类型信息
|
||||
*/
|
||||
protected JsonTypeReference(Type type) {
|
||||
this.type = Objects.requireNonNull(type, "Type cannot be null");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建类型引用实例
|
||||
* @param <T> 目标类型
|
||||
* @return 类型引用实例
|
||||
*/
|
||||
public static <T> JsonTypeReference<T> of() {
|
||||
return new JsonTypeReference<T>() {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Class 创建类型引用
|
||||
* @param clazz 目标类
|
||||
* @param <T> 目标类型
|
||||
* @return 类型引用实例
|
||||
*/
|
||||
public static <T> JsonTypeReference<T> of(Class<T> clazz) {
|
||||
return new JsonTypeReference<T>(clazz) {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Type 创建类型引用
|
||||
* @param type 目标类型
|
||||
* @param <T> 目标类型
|
||||
* @return 类型引用实例
|
||||
*/
|
||||
public static <T> JsonTypeReference<T> of(Type type) {
|
||||
return new JsonTypeReference<T>(type) {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始类型(去掉泛型参数的类型)
|
||||
* @return 原始类型 Class
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<T> getRawType() {
|
||||
Type rawType = type;
|
||||
|
||||
// 如果是参数化类型,则提取原始类型部分
|
||||
if (type instanceof ParameterizedType) {
|
||||
rawType = ((ParameterizedType) type).getRawType();
|
||||
}
|
||||
|
||||
if (rawType instanceof Class) {
|
||||
return (Class<T>) rawType;
|
||||
}
|
||||
|
||||
throw new IllegalStateException("无法获取原始类型: " + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
JsonTypeReference<?> that = (JsonTypeReference<?>) o;
|
||||
|
||||
// 对于 ParameterizedType,需要更完整的比较
|
||||
if (
|
||||
this.type instanceof ParameterizedType &&
|
||||
that.type instanceof ParameterizedType
|
||||
) {
|
||||
ParameterizedType thisParamType = (ParameterizedType) this.type;
|
||||
ParameterizedType thatParamType = (ParameterizedType) that.type;
|
||||
|
||||
return (
|
||||
Objects.equals(
|
||||
thisParamType.getRawType(),
|
||||
thatParamType.getRawType()
|
||||
) &&
|
||||
Arrays.equals(
|
||||
thisParamType.getActualTypeArguments(),
|
||||
thatParamType.getActualTypeArguments()
|
||||
) &&
|
||||
Objects.equals(
|
||||
thisParamType.getOwnerType(),
|
||||
thatParamType.getOwnerType()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Objects.equals(type, that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// 针对 ParameterizedType 进行完整哈希计算
|
||||
if (type instanceof ParameterizedType) {
|
||||
ParameterizedType paramType = (ParameterizedType) type;
|
||||
return Objects.hash(
|
||||
paramType.getRawType(),
|
||||
Arrays.hashCode(paramType.getActualTypeArguments()),
|
||||
paramType.getOwnerType()
|
||||
);
|
||||
}
|
||||
return Objects.hash(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JsonTypeReference{" + type + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(JsonTypeReference<T> o) {
|
||||
return this.type.toString().compareTo(o.type.toString());
|
||||
}
|
||||
}
|
||||
253
src/com/mingliqiye/utils/json/JsonTypeUtils.java
Normal file
253
src/com/mingliqiye/utils/json/JsonTypeUtils.java
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JsonTypeUtils.java
|
||||
* LastUpdate 2025-09-09 09:18:08
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.json;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* JSON 类型工具类,提供类型相关的工具方法
|
||||
*/
|
||||
public class JsonTypeUtils {
|
||||
|
||||
private JsonTypeUtils() {
|
||||
// 工具类,防止实例化
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查给定的类型是否是指定类或其子类/实现类。
|
||||
*
|
||||
* @param type 要检查的类型
|
||||
* @param expectedClass 期望匹配的类
|
||||
* @return 如果类型匹配则返回 true,否则返回 false
|
||||
*/
|
||||
public static boolean isTypeOf(Type type, Class<?> expectedClass) {
|
||||
if (type instanceof Class) {
|
||||
return expectedClass.isAssignableFrom((Class<?>) type);
|
||||
} else if (type instanceof ParameterizedType) {
|
||||
return isTypeOf(
|
||||
((ParameterizedType) type).getRawType(),
|
||||
expectedClass
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取泛型类型的参数类型。
|
||||
*
|
||||
* @param type 泛型类型
|
||||
* @param index 参数索引(从0开始)
|
||||
* @return 指定位置的泛型参数类型
|
||||
* @throws IllegalArgumentException 当无法获取指定索引的泛型参数时抛出异常
|
||||
*/
|
||||
public static Type getGenericParameter(Type type, int index) {
|
||||
if (type instanceof ParameterizedType) {
|
||||
Type[] typeArgs =
|
||||
((ParameterizedType) type).getActualTypeArguments();
|
||||
if (index >= 0 && index < typeArgs.length) {
|
||||
return typeArgs[index];
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"无法获取泛型参数: " + type + " at index " + index
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型名称,支持普通类和泛型类型。
|
||||
*
|
||||
* @param type 类型对象
|
||||
* @return 类型名称字符串
|
||||
*/
|
||||
public static String getTypeName(Type type) {
|
||||
if (type instanceof Class) {
|
||||
return ((Class<?>) type).getSimpleName();
|
||||
} else if (type instanceof ParameterizedType) {
|
||||
ParameterizedType pType = (ParameterizedType) type;
|
||||
Class<?> rawType = (Class<?>) pType.getRawType();
|
||||
Type[] typeArgs = pType.getActualTypeArguments();
|
||||
|
||||
StringBuilder sb = new StringBuilder(rawType.getSimpleName());
|
||||
sb.append("<");
|
||||
for (int i = 0; i < typeArgs.length; i++) {
|
||||
if (i > 0) sb.append(", ");
|
||||
sb.append(getTypeName(typeArgs[i]));
|
||||
}
|
||||
sb.append(">");
|
||||
return sb.toString();
|
||||
}
|
||||
return type.getTypeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个表示数组类型的引用对象。
|
||||
*
|
||||
* @param componentType 数组元素的类型
|
||||
* @param <T> 元素类型
|
||||
* @return 表示数组类型的 JsonTypeReference 对象
|
||||
*/
|
||||
public static <T> JsonTypeReference<T[]> arrayType(Class<T> componentType) {
|
||||
return new JsonTypeReference<T[]>() {
|
||||
private final Type arrayType = java.lang.reflect.Array.newInstance(
|
||||
componentType,
|
||||
0
|
||||
).getClass();
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return new ParameterizedType() {
|
||||
private final Type[] actualTypeArguments = new Type[] {
|
||||
componentType,
|
||||
};
|
||||
|
||||
@Override
|
||||
public Type[] getActualTypeArguments() {
|
||||
return actualTypeArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getRawType() {
|
||||
return arrayType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getOwnerType() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个表示 List 类型的引用对象。
|
||||
*
|
||||
* @param componentType List 中元素的类型
|
||||
* @param <T> 元素类型
|
||||
* @return 表示 List 类型的 JsonTypeReference 对象
|
||||
* @throws IllegalArgumentException 如果 componentType 为 null,则抛出异常
|
||||
*/
|
||||
public static <T> JsonTypeReference<List<T>> listType(
|
||||
Class<T> componentType
|
||||
) {
|
||||
if (componentType == null) {
|
||||
throw new IllegalArgumentException("componentType cannot be null");
|
||||
}
|
||||
|
||||
return new JsonTypeReference<List<T>>() {
|
||||
@Override
|
||||
public Type getType() {
|
||||
return new ParameterizedType() {
|
||||
@Override
|
||||
public Type[] getActualTypeArguments() {
|
||||
return new Type[] { componentType };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getRawType() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getOwnerType() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个表示 Map 类型的引用对象。
|
||||
*
|
||||
* @param keyType Map 键的类型
|
||||
* @param valueType Map 值的类型
|
||||
* @param <K> 键类型
|
||||
* @param <V> 值类型
|
||||
* @return 表示 Map 类型的 JsonTypeReference 对象
|
||||
* @throws IllegalArgumentException 如果 keyType 或 valueType 为 null,则抛出异常
|
||||
*/
|
||||
public static <K, V> JsonTypeReference<Map<K, V>> MapType(
|
||||
Class<K> keyType,
|
||||
Class<V> valueType
|
||||
) {
|
||||
if (keyType == null) {
|
||||
throw new IllegalArgumentException("keyType cannot be null");
|
||||
}
|
||||
if (valueType == null) {
|
||||
throw new IllegalArgumentException("valueType cannot be null");
|
||||
}
|
||||
|
||||
return new JsonTypeReference<Map<K, V>>() {
|
||||
@Override
|
||||
public Type getType() {
|
||||
return new ParameterizedType() {
|
||||
@Override
|
||||
public Type[] getActualTypeArguments() {
|
||||
return new Type[] { keyType, valueType };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getRawType() {
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getOwnerType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof ParameterizedType)) return false;
|
||||
|
||||
ParameterizedType that = (ParameterizedType) obj;
|
||||
return (
|
||||
Objects.equals(getRawType(), that.getRawType()) &&
|
||||
Arrays.equals(
|
||||
getActualTypeArguments(),
|
||||
that.getActualTypeArguments()
|
||||
) &&
|
||||
Objects.equals(getOwnerType(), that.getOwnerType())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (
|
||||
Arrays.hashCode(getActualTypeArguments()) ^
|
||||
Objects.hashCode(getRawType()) ^
|
||||
Objects.hashCode(getOwnerType())
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Description.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Extra.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile MinecraftServerStatus.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile PlayerSample.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Players.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile SLP.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Version.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.minecraft.slp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile NetworkAddress.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.network;
|
||||
|
||||
import com.mingliqiye.utils.string.StringUtil;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile NetworkEndpoint.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.network;
|
||||
|
||||
import com.mingliqiye.utils.string.StringUtil;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile NetworkException.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.network;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile NetworkPort.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.network;
|
||||
|
||||
import com.mingliqiye.utils.string.StringUtil;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile OsPath.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.path;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile RandomBytes.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.random;
|
||||
|
||||
import com.mingliqiye.utils.collection.ForEach;
|
||||
@ -21,7 +43,7 @@ public class RandomBytes {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 生成指定长度的随机字节数组
|
||||
* 从给定的字节数组中随机选择字节来填充新数组
|
||||
*
|
||||
@ -38,7 +60,6 @@ public class RandomBytes {
|
||||
return rbytes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成指定范围内的随机字节
|
||||
* @param from 起始字节值(包含)
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile RandomInt.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.random;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile RandomString.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.random;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,22 +1,45 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile AutoConfiguration.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.springboot.autoconfigure;
|
||||
|
||||
import com.mingliqiye.utils.bean.springboot.SpringBeanUtil;
|
||||
import com.mingliqiye.utils.collection.ForEach;
|
||||
import com.mingliqiye.utils.jackson.Serializers;
|
||||
import com.mingliqiye.utils.json.JacksonJsonApi;
|
||||
import com.mingliqiye.utils.json.JsonApi;
|
||||
import com.mingliqiye.utils.time.DateTime;
|
||||
import com.mingliqiye.utils.time.Formatter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author MingLiPro
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(AutoConfiguration.class)
|
||||
@ComponentScan({ SpringBeanUtil.PACKAGE_NAME })
|
||||
@ -33,67 +56,48 @@ public class AutoConfiguration {
|
||||
"| $$ | \\_/ $$ |$$$$$$$$\\\\$$$$$$ | $$ | \\$$$$$$ | |\n" +
|
||||
"| \\__| \\__|\\________|\\______/ \\__| \\______/ |\n";
|
||||
private static String banner2;
|
||||
private boolean isloadObjMapper;
|
||||
private final Logger log = LoggerFactory.getLogger(AutoConfiguration.class);
|
||||
private com.fasterxml.jackson.databind.ObjectMapper objectMapper;
|
||||
|
||||
public AutoConfiguration() throws IOException {
|
||||
print();
|
||||
public AutoConfiguration() {}
|
||||
|
||||
try {
|
||||
Class<?> clasz = ClassLoader.getSystemClassLoader().loadClass(
|
||||
"com.fasterxml.jackson.databind.ObjectMapper"
|
||||
);
|
||||
isloadObjMapper = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
log.info(
|
||||
"Jackson ObjectMapper not found in classpath. Jackson serialization features will be disabled."
|
||||
);
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (isloadObjMapper) {
|
||||
log.info("init ObjectMapper");
|
||||
Serializers.addSerializers(
|
||||
SpringBeanUtil.getBean(
|
||||
com.fasterxml.jackson.databind.ObjectMapper.class
|
||||
public static void printBanner() {
|
||||
StringBuilder bannerBuilder = new StringBuilder(banner);
|
||||
try (
|
||||
InputStream inputStream =
|
||||
AutoConfiguration.class.getResourceAsStream(
|
||||
"/META-INF/meta-data"
|
||||
)
|
||||
);
|
||||
log.info("add ObjectMapper Serializers OK");
|
||||
} else {
|
||||
log.info("ObjectMapper is Not Found");
|
||||
}
|
||||
}
|
||||
|
||||
public void print() throws IOException {
|
||||
banner2 = banner;
|
||||
InputStream inputStream = AutoConfiguration.class.getResourceAsStream(
|
||||
"/META-INF/meta-data"
|
||||
);
|
||||
int readlen;
|
||||
byte[] buffer = new byte[1024];
|
||||
StringBuilder metaData = new StringBuilder();
|
||||
while ((readlen = inputStream.read(buffer)) != -1) {
|
||||
metaData.append(new String(buffer, 0, readlen));
|
||||
}
|
||||
ForEach.forEach(metaData.toString().split("\n"), (s, i) -> {
|
||||
String[] d = s.trim().split("=", 2);
|
||||
if (d.length >= 2) {
|
||||
String content = "| " + d[0] + ": " + d[1];
|
||||
// 直接计算需要的空格数来对齐
|
||||
int targetLength = 56; // 为右侧的 | 留出空间
|
||||
if (content.length() < targetLength) {
|
||||
int spacesNeeded = targetLength - content.length();
|
||||
StringBuilder da = new StringBuilder(content);
|
||||
for (int ia = 0; ia < spacesNeeded; ia++) {
|
||||
da.append(" ");
|
||||
}
|
||||
banner2 += da + "|\n";
|
||||
} else {
|
||||
banner2 += content.substring(0, targetLength) + "|\n";
|
||||
}
|
||||
) {
|
||||
if (inputStream == null) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
int readlen;
|
||||
byte[] buffer = new byte[1024];
|
||||
StringBuilder metaData = new StringBuilder();
|
||||
while ((readlen = inputStream.read(buffer)) != -1) {
|
||||
metaData.append(new String(buffer, 0, readlen));
|
||||
}
|
||||
ForEach.forEach(metaData.toString().split("\n"), (s, i) -> {
|
||||
String[] d = s.trim().split("=", 2);
|
||||
if (d.length >= 2) {
|
||||
String content = "| " + d[0] + ": " + d[1];
|
||||
int targetLength = 56;
|
||||
if (content.length() < targetLength) {
|
||||
bannerBuilder.append(
|
||||
String.format("%-" + targetLength + "s|\n", content)
|
||||
);
|
||||
} else {
|
||||
bannerBuilder
|
||||
.append(content, 0, targetLength)
|
||||
.append("|\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
banner2 = bannerBuilder.toString();
|
||||
System.out.printf(
|
||||
banner2,
|
||||
DateTime.now().format(Formatter.STANDARD_DATETIME_MILLISECOUND7)
|
||||
@ -102,4 +106,37 @@ public class AutoConfiguration {
|
||||
"---------------------------------------------------------"
|
||||
);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
try {
|
||||
Class.forName("com.fasterxml.jackson.databind.ObjectMapper");
|
||||
log.info("init ObjectMapper");
|
||||
objectMapper = SpringBeanUtil.getBean(
|
||||
com.fasterxml.jackson.databind.ObjectMapper.class
|
||||
);
|
||||
Serializers.addSerializers(objectMapper);
|
||||
log.info("add ObjectMapper Serializers OK");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
log.info(
|
||||
"Jackson ObjectMapper not found in classpath. Jackson serialization features will be disabled."
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to initialize ObjectMapper", e);
|
||||
}
|
||||
printBanner();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnClass(name = "com.fasterxml.jackson.databind.ObjectMapper")
|
||||
public JsonApi jsonApi() {
|
||||
if (objectMapper == null) {
|
||||
log.warn(
|
||||
"ObjectMapper is not available, returning null for JsonApi"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
log.info("Creating JacksonJsonApi bean");
|
||||
return new JacksonJsonApi(objectMapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile CStream.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.stream;
|
||||
|
||||
import com.mingliqiye.utils.collection.ForEach;
|
||||
@ -10,22 +32,22 @@ import java.util.stream.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 自定义的 ListStream 实现类,用于对集合进行流式操作。
|
||||
* 该类实现了 Java 标准库中的 ListStream 接口,并基于 List 数据结构提供了一系列流式处理方法。
|
||||
* 自定义的 CStream 实现类,用于对集合进行流式操作。
|
||||
* 该类实现了 Java 标准库中的 CStream 接口,并基于 List 数据结构提供了一系列流式处理方法。
|
||||
*
|
||||
* @author MingLiPro
|
||||
* @param <T> 流中元素的类型
|
||||
*/
|
||||
public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
public class CStream<T> implements java.util.stream.Stream<T> {
|
||||
|
||||
private final List<T> list;
|
||||
|
||||
/**
|
||||
* 构造方法,初始化 ListStream 实例。
|
||||
* 构造方法,初始化 CStream 实例。
|
||||
*
|
||||
* @param list 用于构造 ListStream 的列表数据,如果为 null 则使用空列表
|
||||
* @param list 用于构造 CStream 的列表数据,如果为 null 则使用空列表
|
||||
*/
|
||||
private ListStream(List<T> list) {
|
||||
private CStream(List<T> list) {
|
||||
this.list = list != null ? list : Lists.newArrayList();
|
||||
}
|
||||
|
||||
@ -496,6 +518,12 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
return Collectors.toMap(keyMapper, valueMapper, mergeFunction);
|
||||
}
|
||||
|
||||
public static <T, K> Collector<T, ?, @NotNull Map<K, T>> toMap(
|
||||
@NotNull Function<? super T, ? extends K> keyMapper
|
||||
) {
|
||||
return Collectors.toMap(keyMapper, CStream::getThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个收集器,将元素转换为 Map,指定键冲突合并函数和 Map 工厂。
|
||||
*
|
||||
@ -648,43 +676,47 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含指定元素的 ListStream。
|
||||
* 创建一个包含指定元素的 CStream。
|
||||
*
|
||||
* @param ts 可变参数,表示要包含在 ListStream 中的元素
|
||||
* @param ts 可变参数,表示要包含在 CStream 中的元素
|
||||
* @param <T> 元素类型
|
||||
* @return 包含指定元素的新 ListStream 实例
|
||||
* @return 包含指定元素的新 CStream 实例
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> ListStream<T> of(T... ts) {
|
||||
return new ListStream<>(Lists.newArrayList(ts));
|
||||
public static <T> CStream<T> of(T... ts) {
|
||||
return new CStream<>(Lists.newArrayList(ts));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含指定列表元素的 ListStream。
|
||||
* 创建一个包含指定列表元素的 CStream。
|
||||
*
|
||||
* @param ts 列表,表示要包含在 ListStream 中的元素
|
||||
* @param ts 列表,表示要包含在 CStream 中的元素
|
||||
* @param <T> 元素类型
|
||||
* @return 包含指定元素的新 ListStream 实例
|
||||
* @return 包含指定元素的新 CStream 实例
|
||||
*/
|
||||
public static <T> ListStream<T> of(List<T> ts) {
|
||||
return new ListStream<>(Lists.newArrayList(ts));
|
||||
public static <T> CStream<T> of(Collection<T> ts) {
|
||||
return new CStream<>(Lists.newArrayList(ts));
|
||||
}
|
||||
|
||||
public static <T> T getThis(T t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据给定的谓词条件过滤流中的元素。
|
||||
*
|
||||
* @param predicate 用于测试元素是否应保留的谓词函数
|
||||
* @return 包含满足条件元素的新 ListStream 实例
|
||||
* @return 包含满足条件元素的新 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> filter(Predicate<? super T> predicate) {
|
||||
public CStream<T> filter(Predicate<? super T> predicate) {
|
||||
List<T> result = Lists.newArrayList();
|
||||
for (T item : list) {
|
||||
if (predicate.test(item)) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
return new ListStream<>(result);
|
||||
return new CStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -692,9 +724,9 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
*
|
||||
* @param propertyExtractor 属性提取函数
|
||||
* @param targetValue 目标值
|
||||
* @return 包含满足条件元素的新 ListStream 实例
|
||||
* @return 包含满足条件元素的新 CStream 实例
|
||||
*/
|
||||
public ListStream<T> filter(
|
||||
public CStream<T> filter(
|
||||
Function<T, Object> propertyExtractor,
|
||||
Object targetValue
|
||||
) {
|
||||
@ -704,7 +736,7 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
return new ListStream<>(result);
|
||||
return new CStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -712,15 +744,15 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
*
|
||||
* @param mapper 映射函数,将元素从类型 T 转换为类型 R
|
||||
* @param <R> 映射后元素的类型
|
||||
* @return 包含转换后元素的新 ListStream 实例
|
||||
* @return 包含转换后元素的新 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public <R> ListStream<R> map(Function<? super T, ? extends R> mapper) {
|
||||
public <R> CStream<R> map(Function<? super T, ? extends R> mapper) {
|
||||
List<R> result = Lists.newArrayList();
|
||||
for (T item : list) {
|
||||
result.add(mapper.apply(item));
|
||||
}
|
||||
return new ListStream<>(result);
|
||||
return new CStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -777,12 +809,12 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
/**
|
||||
* 将流中的每个元素通过映射函数转换为另一个流,并将所有结果流合并为一个流。
|
||||
*
|
||||
* @param mapper 映射函数,将元素从类型 T 转换为另一个 ListStream
|
||||
* @param mapper 映射函数,将元素从类型 T 转换为另一个 CStream
|
||||
* @param <R> 映射后流中元素的类型
|
||||
* @return 合并后的 ListStream 实例
|
||||
* @return 合并后的 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public <R> ListStream<R> flatMap(
|
||||
public <R> CStream<R> flatMap(
|
||||
Function<
|
||||
? super T,
|
||||
? extends java.util.stream.Stream<? extends R>
|
||||
@ -795,7 +827,7 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
stream.forEach(result::add);
|
||||
}
|
||||
}
|
||||
return new ListStream<>(result);
|
||||
return new CStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -840,47 +872,47 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
/**
|
||||
* 去除流中重复的元素,保持原有顺序。
|
||||
*
|
||||
* @return 包含去重后元素的新 ListStream 实例
|
||||
* @return 包含去重后元素的新 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> distinct() {
|
||||
public CStream<T> distinct() {
|
||||
Set<T> seen = new LinkedHashSet<>(list);
|
||||
return new ListStream<>(new ArrayList<>(seen));
|
||||
return new CStream<>(new ArrayList<>(seen));
|
||||
}
|
||||
|
||||
/**
|
||||
* 对流中的元素进行自然排序。
|
||||
*
|
||||
* @return 排序后的新 ListStream 实例
|
||||
* @return 排序后的新 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> sorted() {
|
||||
public CStream<T> sorted() {
|
||||
List<T> sortedList = Lists.newArrayList(list);
|
||||
Collections.sort((List<? extends Comparable>) sortedList);
|
||||
return new ListStream<>(sortedList);
|
||||
return new CStream<>(sortedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据给定的比较器对流中的元素进行排序。
|
||||
*
|
||||
* @param comparator 用于比较元素的比较器
|
||||
* @return 排序后的新 ListStream 实例
|
||||
* @return 排序后的新 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> sorted(Comparator<? super T> comparator) {
|
||||
public CStream<T> sorted(Comparator<? super T> comparator) {
|
||||
List<T> sortedList = Lists.newArrayList(list);
|
||||
sortedList.sort(comparator);
|
||||
return new ListStream<>(sortedList);
|
||||
return new CStream<>(sortedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对流中的每个元素执行指定的操作,但不改变流本身。
|
||||
*
|
||||
* @param action 要对每个元素执行的操作
|
||||
* @return 当前 ListStream 实例
|
||||
* @return 当前 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> peek(Consumer<? super T> action) {
|
||||
public CStream<T> peek(Consumer<? super T> action) {
|
||||
for (T item : list) {
|
||||
action.accept(item);
|
||||
}
|
||||
@ -891,16 +923,16 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
* 截取流中前 maxSize 个元素组成新的流。
|
||||
*
|
||||
* @param maxSize 要截取的最大元素数量
|
||||
* @return 截取后的新 ListStream 实例
|
||||
* @return 截取后的新 CStream 实例
|
||||
* @throws IllegalArgumentException 如果 maxSize 为负数
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> limit(long maxSize) {
|
||||
public CStream<T> limit(long maxSize) {
|
||||
if (maxSize < 0) {
|
||||
throw new IllegalArgumentException("maxSize must be non-negative");
|
||||
}
|
||||
if (maxSize == 0) {
|
||||
return new ListStream<>(Lists.newArrayList());
|
||||
return new CStream<>(Lists.newArrayList());
|
||||
}
|
||||
|
||||
List<T> limitedList = Lists.newArrayList();
|
||||
@ -912,23 +944,23 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
limitedList.add(item);
|
||||
count++;
|
||||
}
|
||||
return new ListStream<>(limitedList);
|
||||
return new CStream<>(limitedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳过流中前 n 个元素,返回剩余元素组成的新流。
|
||||
*
|
||||
* @param n 要跳过的元素数量
|
||||
* @return 跳过后的新 ListStream 实例
|
||||
* @return 跳过后的新 CStream 实例
|
||||
* @throws IllegalArgumentException 如果 n 为负数
|
||||
*/
|
||||
@Override
|
||||
public ListStream<T> skip(long n) {
|
||||
public CStream<T> skip(long n) {
|
||||
if (n < 0) {
|
||||
throw new IllegalArgumentException("n must be non-negative");
|
||||
}
|
||||
if (n == 0) {
|
||||
return new ListStream<>(Lists.newArrayList(list));
|
||||
return new CStream<>(Lists.newArrayList(list));
|
||||
}
|
||||
|
||||
List<T> skippedList = Lists.newArrayList();
|
||||
@ -939,7 +971,7 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return new ListStream<>(skippedList);
|
||||
return new CStream<>(skippedList);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1071,10 +1103,10 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (list.isEmpty()) {
|
||||
return "ListStream()";
|
||||
return "CStream()";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ListStream(");
|
||||
sb.append("CStream(");
|
||||
forEach((item, index) -> {
|
||||
sb.append(item);
|
||||
if (index != list.size() - 1) {
|
||||
@ -1273,7 +1305,7 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
* @return 当前流的顺序版本
|
||||
*/
|
||||
@Override
|
||||
public @NotNull ListStream<T> sequential() {
|
||||
public @NotNull CStream<T> sequential() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1283,8 +1315,8 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
* @return 当前流的并行版本
|
||||
*/
|
||||
@Override
|
||||
public @NotNull ListStream<T> parallel() {
|
||||
return new ListStream<>(list);
|
||||
public @NotNull CStream<T> parallel() {
|
||||
return new CStream<>(list);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1293,7 +1325,7 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
* @return 当前流的无序版本
|
||||
*/
|
||||
@Override
|
||||
public @NotNull ListStream<T> unordered() {
|
||||
public @NotNull CStream<T> unordered() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1301,10 +1333,10 @@ public class ListStream<T> implements java.util.stream.Stream<T> {
|
||||
* 注册一个关闭处理器,在流关闭时执行。
|
||||
*
|
||||
* @param closeHandler 关闭处理器
|
||||
* @return 当前 ListStream 实例
|
||||
* @return 当前 CStream 实例
|
||||
*/
|
||||
@Override
|
||||
public @NotNull ListStream<T> onClose(@NotNull Runnable closeHandler) {
|
||||
public @NotNull CStream<T> onClose(@NotNull Runnable closeHandler) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1,313 +0,0 @@
|
||||
package com.mingliqiye.utils.stream;
|
||||
|
||||
import com.mingliqiye.utils.collection.Lists;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
/**
|
||||
* 用于处理键值对的流实现
|
||||
*
|
||||
* @author MingLiPro
|
||||
* @param <K> 键类型
|
||||
* @param <V> 值类型
|
||||
*/
|
||||
public class MapStream<K, V> {
|
||||
|
||||
private final List<Map.Entry<K, V>> entries;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param entries 包含键值对的列表
|
||||
*/
|
||||
private MapStream(List<Map.Entry<K, V>> entries) {
|
||||
this.entries = entries != null ? entries : Lists.newArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从Map创建MapStream
|
||||
*
|
||||
* @param map 输入Map
|
||||
* @param <K> 键类型
|
||||
* @param <V> 值类型
|
||||
* @return MapStream实例
|
||||
*/
|
||||
public static <K, V> MapStream<K, V> of(Map<K, V> map) {
|
||||
return new MapStream<>(new ArrayList<>(map.entrySet()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从键值对数组创建MapStream
|
||||
*
|
||||
* @param entries 键值对数组
|
||||
* @param <K> 键类型
|
||||
* @param <V> 值类型
|
||||
* @return MapStream实例
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <K, V> MapStream<K, V> of(Map.Entry<K, V>... entries) {
|
||||
return new MapStream<>(Lists.newArrayList(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据键过滤MapStream
|
||||
*
|
||||
* @param keyPredicate 键的谓词条件
|
||||
* @return 过滤后的MapStream
|
||||
*/
|
||||
public MapStream<K, V> filterByKey(Predicate<? super K> keyPredicate) {
|
||||
List<Map.Entry<K, V>> result = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
if (keyPredicate.test(entry.getKey())) {
|
||||
result.add(entry);
|
||||
}
|
||||
}
|
||||
return new MapStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据值过滤MapStream
|
||||
*
|
||||
* @param valuePredicate 值的谓词条件
|
||||
* @return 过滤后的MapStream
|
||||
*/
|
||||
public MapStream<K, V> filterByValue(Predicate<? super V> valuePredicate) {
|
||||
List<Map.Entry<K, V>> result = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
if (valuePredicate.test(entry.getValue())) {
|
||||
result.add(entry);
|
||||
}
|
||||
}
|
||||
return new MapStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤MapStream
|
||||
*
|
||||
* @param predicate 键值对的谓词条件
|
||||
* @return 过滤后的MapStream
|
||||
*/
|
||||
public MapStream<K, V> filter(Predicate<Map.Entry<K, V>> predicate) {
|
||||
List<Map.Entry<K, V>> result = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
if (predicate.test(entry)) {
|
||||
result.add(entry);
|
||||
}
|
||||
}
|
||||
return new MapStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换键
|
||||
*
|
||||
* @param keyMapper 键映射函数
|
||||
* @param <R> 新的键类型
|
||||
* @return 转换后的MapStream
|
||||
*/
|
||||
public <R> MapStream<R, V> mapKey(
|
||||
Function<? super K, ? extends R> keyMapper
|
||||
) {
|
||||
List<Map.Entry<R, V>> result = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
R newKey = keyMapper.apply(entry.getKey());
|
||||
result.add(new AbstractMap.SimpleEntry<>(newKey, entry.getValue()));
|
||||
}
|
||||
return new MapStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换值
|
||||
*
|
||||
* @param valueMapper 值映射函数
|
||||
* @param <R> 新的值类型
|
||||
* @return 转换后的MapStream
|
||||
*/
|
||||
public <R> MapStream<K, R> mapValue(
|
||||
Function<? super V, ? extends R> valueMapper
|
||||
) {
|
||||
List<Map.Entry<K, R>> result = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
R newValue = valueMapper.apply(entry.getValue());
|
||||
result.add(new AbstractMap.SimpleEntry<>(entry.getKey(), newValue));
|
||||
}
|
||||
return new MapStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换键值对
|
||||
*
|
||||
* @param entryMapper 键值对映射函数
|
||||
* @param <R> 新的键类型
|
||||
* @param <S> 新的值类型
|
||||
* @return 转换后的MapStream
|
||||
*/
|
||||
public <R, S> MapStream<R, S> map(
|
||||
Function<Map.Entry<K, V>, Map.Entry<R, S>> entryMapper
|
||||
) {
|
||||
List<Map.Entry<R, S>> result = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
result.add(entryMapper.apply(entry));
|
||||
}
|
||||
return new MapStream<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将键值对流转换为Map
|
||||
*
|
||||
* @return 包含所有键值对的Map
|
||||
*/
|
||||
public Map<K, V> toMap() {
|
||||
Map<K, V> map = new HashMap<>();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将键值对流转换为Map,指定Map类型和键冲突时的合并函数
|
||||
*
|
||||
* @param mapSupplier Map工厂函数
|
||||
* @param mergeFunction 键冲突合并函数
|
||||
* @param <M> Map类型
|
||||
* @return 包含所有键值对的Map
|
||||
*/
|
||||
public <M extends Map<K, V>> M toMap(
|
||||
Supplier<M> mapSupplier,
|
||||
BinaryOperator<V> mergeFunction
|
||||
) {
|
||||
M map = mapSupplier.get();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
map.merge(entry.getKey(), entry.getValue(), mergeFunction);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对每个键值对执行操作
|
||||
*
|
||||
* @param action 要执行的操作
|
||||
*/
|
||||
public void forEach(BiConsumer<? super K, ? super V> action) {
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
action.accept(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算键值对数量
|
||||
*
|
||||
* @return 键值对数量
|
||||
*/
|
||||
public long count() {
|
||||
return entries.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取键的流
|
||||
*
|
||||
* @return 键的流
|
||||
*/
|
||||
public ListStream<K> keys() {
|
||||
List<K> keys = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
keys.add(entry.getKey());
|
||||
}
|
||||
return ListStream.of(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值的流
|
||||
*
|
||||
* @return 值的流
|
||||
*/
|
||||
public ListStream<V> values() {
|
||||
List<V> values = Lists.newArrayList();
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
values.add(entry.getValue());
|
||||
}
|
||||
return ListStream.of(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对键值对进行排序
|
||||
*
|
||||
* @param comparator 比较器
|
||||
* @return 排序后的MapStream
|
||||
*/
|
||||
public MapStream<K, V> sorted(Comparator<Map.Entry<K, V>> comparator) {
|
||||
List<Map.Entry<K, V>> sortedEntries = Lists.newArrayList(entries);
|
||||
sortedEntries.sort(comparator);
|
||||
return new MapStream<>(sortedEntries);
|
||||
}
|
||||
|
||||
/**
|
||||
* 限制键值对数量
|
||||
*
|
||||
* @param maxSize 最大数量
|
||||
* @return 限制后的MapStream
|
||||
*/
|
||||
public MapStream<K, V> limit(long maxSize) {
|
||||
if (maxSize < 0) {
|
||||
throw new IllegalArgumentException("maxSize must be non-negative");
|
||||
}
|
||||
if (maxSize == 0) {
|
||||
return new MapStream<>(Lists.newArrayList());
|
||||
}
|
||||
|
||||
List<Map.Entry<K, V>> limitedEntries = Lists.newArrayList();
|
||||
long count = 0;
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
if (count >= maxSize) {
|
||||
break;
|
||||
}
|
||||
limitedEntries.add(entry);
|
||||
count++;
|
||||
}
|
||||
return new MapStream<>(limitedEntries);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳过指定数量的键值对
|
||||
*
|
||||
* @param n 要跳过的数量
|
||||
* @return 跳过后的MapStream
|
||||
*/
|
||||
public MapStream<K, V> skip(long n) {
|
||||
if (n < 0) {
|
||||
throw new IllegalArgumentException("n must be non-negative");
|
||||
}
|
||||
if (n == 0) {
|
||||
return new MapStream<>(Lists.newArrayList(entries));
|
||||
}
|
||||
|
||||
List<Map.Entry<K, V>> skippedEntries = Lists.newArrayList();
|
||||
long count = 0;
|
||||
for (Map.Entry<K, V> entry : entries) {
|
||||
if (count >= n) {
|
||||
skippedEntries.add(entry);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return new MapStream<>(skippedEntries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (entries.isEmpty()) {
|
||||
return "MapStream()";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("MapStream(");
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
Map.Entry<K, V> entry = entries.get(i);
|
||||
sb.append(entry.getKey()).append("=").append(entry.getValue());
|
||||
if (i != entries.size() - 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,28 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile StringUtil.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.string;
|
||||
|
||||
import com.mingliqiye.utils.callback.P1R1Function;
|
||||
import com.mingliqiye.utils.callback.P1RFunction;
|
||||
import com.mingliqiye.utils.collection.Lists;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -137,7 +159,7 @@ public class StringUtil {
|
||||
public static <P> String join(
|
||||
String separator,
|
||||
List<P> list,
|
||||
P1R1Function<P, String> fun
|
||||
P1RFunction<P, String> fun
|
||||
) {
|
||||
// 处理空列表情况
|
||||
if (list == null || list.isEmpty()) {
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile SystemUtil.java
|
||||
* LastUpdate 2025-09-09 08:37:34
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.system;
|
||||
|
||||
import com.mingliqiye.utils.collection.Lists;
|
||||
|
||||
@ -1,6 +1,29 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile DateTime.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.time;
|
||||
|
||||
import com.mingliqiye.utils.jna.time.WinKernel32;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
@ -26,7 +49,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @see Instant
|
||||
*/
|
||||
@Setter
|
||||
public final class DateTime {
|
||||
public final class DateTime implements Serializable {
|
||||
|
||||
private static final String version = System.getProperty("java.version");
|
||||
private static final WinKernel32 WIN_KERNEL_32;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile DateTimeOffset.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.time;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile DateTimeUnit.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.time;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Formatter.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.time;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Jackson.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.time.serialization;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile DateTimeTypeHandler.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.time.typehandlers;
|
||||
|
||||
import com.mingliqiye.utils.time.DateTime;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile MysqlUUIDv1.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid;
|
||||
|
||||
import lombok.var;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile UUID.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid;
|
||||
|
||||
import com.github.f4b6a3.uuid.UuidCreator;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile UUIDException.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid;
|
||||
|
||||
public class UUIDException extends RuntimeException {
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Jackson.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid.serialization;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile UUIDBinaryTypeHandler.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid.typehandlers;
|
||||
|
||||
import com.mingliqiye.utils.uuid.UUID;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile UUIDConverter.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid.typehandlers;
|
||||
|
||||
import com.mingliqiye.utils.uuid.MysqlUUIDv1;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile UUIDStringTypeHandler.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.uuid.typehandlers;
|
||||
|
||||
import com.mingliqiye.utils.uuid.UUID;
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright 2025 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile VersionUtils.java
|
||||
* LastUpdate 2025-09-09 08:37:33
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.version;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user