diff --git a/build.gradle.kts b/build.gradle.kts index 5352275..2dfdc98 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { 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, diff --git a/gradle.properties b/gradle.properties index 60efbdf..23127a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 407c905..6fdf91c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index ef07e01..d1b5330 100755 --- a/gradlew +++ b/gradlew @@ -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 # ############################################################################## diff --git a/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 00b11b1..d6d2c85 100644 --- a/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -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 diff --git a/settings.gradle.kts b/settings.gradle.kts index 94b1490..50f99da 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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 diff --git a/src/com/mingliqiye/utils/Main.java b/src/com/mingliqiye/utils/Main.java index ca60c5c..97a3fd9 100644 --- a/src/com/mingliqiye/utils/Main.java +++ b/src/com/mingliqiye/utils/Main.java @@ -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 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 numbers = Lists.newArrayList(10, 20, 30); - System.out.println("数字列表: " + numbers); - - List linkedList = Lists.newLinkedList( - "第一个", - "第二个", - "第三个" - ); - System.out.println("链表内容: " + linkedList); + public static void main(String[] args) throws IOException { + AutoConfiguration.printBanner(); } } diff --git a/src/com/mingliqiye/utils/aes/AesUtils.java b/src/com/mingliqiye/utils/aes/AesUtils.java index 9f7ce64..fc98aa0 100644 --- a/src/com/mingliqiye/utils/aes/AesUtils.java +++ b/src/com/mingliqiye/utils/aes/AesUtils.java @@ -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; diff --git a/src/com/mingliqiye/utils/base64/Base64Utils.java b/src/com/mingliqiye/utils/base64/Base64Utils.java index 2f0d5a0..0241857 100644 --- a/src/com/mingliqiye/utils/base64/Base64Utils.java +++ b/src/com/mingliqiye/utils/base64/Base64Utils.java @@ -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; diff --git a/src/com/mingliqiye/utils/bean/Factory.java b/src/com/mingliqiye/utils/bean/Factory.java index 24c2673..80583ca 100644 --- a/src/com/mingliqiye/utils/bean/Factory.java +++ b/src/com/mingliqiye/utils/bean/Factory.java @@ -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; diff --git a/src/com/mingliqiye/utils/bean/annotation/ComponentBean.java b/src/com/mingliqiye/utils/bean/annotation/ComponentBean.java index 82de6fc..dca8912 100644 --- a/src/com/mingliqiye/utils/bean/annotation/ComponentBean.java +++ b/src/com/mingliqiye/utils/bean/annotation/ComponentBean.java @@ -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; diff --git a/src/com/mingliqiye/utils/bean/annotation/InjectBean.java b/src/com/mingliqiye/utils/bean/annotation/InjectBean.java index 9920e61..c0ae276 100644 --- a/src/com/mingliqiye/utils/bean/annotation/InjectBean.java +++ b/src/com/mingliqiye/utils/bean/annotation/InjectBean.java @@ -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; diff --git a/src/com/mingliqiye/utils/bean/springboot/SpringBeanUtil.java b/src/com/mingliqiye/utils/bean/springboot/SpringBeanUtil.java index 9af9dfb..9aa7c0b 100644 --- a/src/com/mingliqiye/utils/bean/springboot/SpringBeanUtil.java +++ b/src/com/mingliqiye/utils/bean/springboot/SpringBeanUtil.java @@ -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; diff --git a/src/com/mingliqiye/utils/bytes/ByteUtil.java b/src/com/mingliqiye/utils/bytes/ByteUtil.java index 31b75ff..190a6d5 100644 --- a/src/com/mingliqiye/utils/bytes/ByteUtil.java +++ b/src/com/mingliqiye/utils/bytes/ByteUtil.java @@ -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; diff --git a/src/com/mingliqiye/utils/callback/P10Function.java b/src/com/mingliqiye/utils/callback/P10Function.java new file mode 100644 index 0000000..afb3501 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P10Function.java @@ -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 { + void call( + P p, + P1 p1, + P2 p2, + P3 p3, + P4 p4, + P5 p5, + P6 p6, + P7 p7, + P8 p8, + P9 p9 + ); +} diff --git a/src/com/mingliqiye/utils/callback/P10RFunction.java b/src/com/mingliqiye/utils/callback/P10RFunction.java new file mode 100644 index 0000000..15675c4 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P10RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9); +} diff --git a/src/com/mingliqiye/utils/callback/P1Function.java b/src/com/mingliqiye/utils/callback/P1Function.java new file mode 100644 index 0000000..0ac0146 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P1Function.java @@ -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

{ + void call(P p); +} diff --git a/src/com/mingliqiye/utils/callback/P1R1Function.java b/src/com/mingliqiye/utils/callback/P1R1Function.java deleted file mode 100644 index 1a5dd0a..0000000 --- a/src/com/mingliqiye/utils/callback/P1R1Function.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mingliqiye.utils.callback; - -/** - * PRFunction接口表示一个接收参数P并返回结果R的函数式接口 - *

- * 该接口使用@,表明它是一个函数式接口, - * 只包含一个抽象方法FunctionalInterface注解标记call,可用于Lambda表达式和方法引用 - *

- * - * @author MingLiPro - * @param

函数接收的参数类型 - * @param 函数返回的结果类型 - */ -@FunctionalInterface -public interface P1R1Function { - /** - * 执行函数调用 - * - * @param p 输入参数 - * @return 函数执行结果 - */ - R call(P p); -} diff --git a/src/com/mingliqiye/utils/callback/P1RFunction.java b/src/com/mingliqiye/utils/callback/P1RFunction.java new file mode 100644 index 0000000..def8233 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P1RFunction.java @@ -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 { + R call(P p); +} diff --git a/src/com/mingliqiye/utils/callback/P2Function.java b/src/com/mingliqiye/utils/callback/P2Function.java new file mode 100644 index 0000000..4295467 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P2Function.java @@ -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 { + void call(P p, P1 p1); +} diff --git a/src/com/mingliqiye/utils/callback/P2RFunction.java b/src/com/mingliqiye/utils/callback/P2RFunction.java new file mode 100644 index 0000000..9a41f55 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P2RFunction.java @@ -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 { + R call(P p, P1 p1); +} diff --git a/src/com/mingliqiye/utils/callback/P3Function.java b/src/com/mingliqiye/utils/callback/P3Function.java new file mode 100644 index 0000000..05a3d6a --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P3Function.java @@ -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 { + void call(P p, P1 p1, P2 p2); +} diff --git a/src/com/mingliqiye/utils/callback/P3RFunction.java b/src/com/mingliqiye/utils/callback/P3RFunction.java new file mode 100644 index 0000000..a6d9797 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P3RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2); +} diff --git a/src/com/mingliqiye/utils/callback/P4Function.java b/src/com/mingliqiye/utils/callback/P4Function.java new file mode 100644 index 0000000..431d3cc --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P4Function.java @@ -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 { + void call(P p, P1 p1, P2 p2, P3 p3); +} diff --git a/src/com/mingliqiye/utils/callback/P4RFunction.java b/src/com/mingliqiye/utils/callback/P4RFunction.java new file mode 100644 index 0000000..787d2d8 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P4RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3); +} diff --git a/src/com/mingliqiye/utils/callback/P5Function.java b/src/com/mingliqiye/utils/callback/P5Function.java new file mode 100644 index 0000000..6c6e2c9 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P5Function.java @@ -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 { + void call(P p, P1 p1, P2 p2, P3 p3, P4 p4); +} diff --git a/src/com/mingliqiye/utils/callback/P5RFunction.java b/src/com/mingliqiye/utils/callback/P5RFunction.java new file mode 100644 index 0000000..83aa373 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P5RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3, P4 p4); +} diff --git a/src/com/mingliqiye/utils/callback/P6Function.java b/src/com/mingliqiye/utils/callback/P6Function.java new file mode 100644 index 0000000..e29d495 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P6Function.java @@ -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 { + void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5); +} diff --git a/src/com/mingliqiye/utils/callback/P6RFunction.java b/src/com/mingliqiye/utils/callback/P6RFunction.java new file mode 100644 index 0000000..9dd1baf --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P6RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5); +} diff --git a/src/com/mingliqiye/utils/callback/P7Function.java b/src/com/mingliqiye/utils/callback/P7Function.java new file mode 100644 index 0000000..53006d2 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P7Function.java @@ -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 { + void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6); +} diff --git a/src/com/mingliqiye/utils/callback/P7RFunction.java b/src/com/mingliqiye/utils/callback/P7RFunction.java new file mode 100644 index 0000000..5dd6c06 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P7RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6); +} diff --git a/src/com/mingliqiye/utils/callback/P8Function.java b/src/com/mingliqiye/utils/callback/P8Function.java new file mode 100644 index 0000000..68d8f8b --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P8Function.java @@ -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 { + void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7); +} diff --git a/src/com/mingliqiye/utils/callback/P8RFunction.java b/src/com/mingliqiye/utils/callback/P8RFunction.java new file mode 100644 index 0000000..76316c7 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P8RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7); +} diff --git a/src/com/mingliqiye/utils/callback/P9Function.java b/src/com/mingliqiye/utils/callback/P9Function.java new file mode 100644 index 0000000..4f7cfb0 --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P9Function.java @@ -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 { + void call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8); +} diff --git a/src/com/mingliqiye/utils/callback/P9RFunction.java b/src/com/mingliqiye/utils/callback/P9RFunction.java new file mode 100644 index 0000000..fe472aa --- /dev/null +++ b/src/com/mingliqiye/utils/callback/P9RFunction.java @@ -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 { + R call(P p, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8); +} diff --git a/src/com/mingliqiye/utils/clone/CloneUtil.java b/src/com/mingliqiye/utils/clone/CloneUtil.java new file mode 100644 index 0000000..03bdb18 --- /dev/null +++ b/src/com/mingliqiye/utils/clone/CloneUtil.java @@ -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 对象的类型,必须实现Serializable接口 + * @return 深拷贝后的新对象,与原对象内容相同但内存地址不同 + * @throws RuntimeException 当序列化或反序列化过程中发生IO异常或类未找到异常时抛出 + */ + public static 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 对象类型参数 + * @param object 需要克隆的对象实例 + * @param jsonApi JSON序列化接口实现 + * @return 克隆后的对象实例 + */ + public static 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 + ); + } + } +} diff --git a/src/com/mingliqiye/utils/collection/Collection.java b/src/com/mingliqiye/utils/collection/Collection.java index 369c254..5aa50d1 100644 --- a/src/com/mingliqiye/utils/collection/Collection.java +++ b/src/com/mingliqiye/utils/collection/Collection.java @@ -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; diff --git a/src/com/mingliqiye/utils/collection/ForEach.java b/src/com/mingliqiye/utils/collection/ForEach.java index 03f4dde..55d6434 100644 --- a/src/com/mingliqiye/utils/collection/ForEach.java +++ b/src/com/mingliqiye/utils/collection/ForEach.java @@ -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.*; diff --git a/src/com/mingliqiye/utils/collection/Lists.java b/src/com/mingliqiye/utils/collection/Lists.java index 23b182e..5855766 100644 --- a/src/com/mingliqiye/utils/collection/Lists.java +++ b/src/com/mingliqiye/utils/collection/Lists.java @@ -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实现的便捷方法。 * diff --git a/src/com/mingliqiye/utils/collection/Maps.java b/src/com/mingliqiye/utils/collection/Maps.java index 29db9c1..6a5a703 100644 --- a/src/com/mingliqiye/utils/collection/Maps.java +++ b/src/com/mingliqiye/utils/collection/Maps.java @@ -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实现的便捷方法。 diff --git a/src/com/mingliqiye/utils/collection/Sets.java b/src/com/mingliqiye/utils/collection/Sets.java index d638461..1e5ec4f 100644 --- a/src/com/mingliqiye/utils/collection/Sets.java +++ b/src/com/mingliqiye/utils/collection/Sets.java @@ -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.*; diff --git a/src/com/mingliqiye/utils/concurrent/IsChanged.java b/src/com/mingliqiye/utils/concurrent/IsChanged.java index 82b4600..c3bf1b7 100644 --- a/src/com/mingliqiye/utils/concurrent/IsChanged.java +++ b/src/com/mingliqiye/utils/concurrent/IsChanged.java @@ -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; diff --git a/src/com/mingliqiye/utils/data/ThreadLocalDataHolder.java b/src/com/mingliqiye/utils/data/ThreadLocalDataHolder.java index 2f67369..0d34737 100644 --- a/src/com/mingliqiye/utils/data/ThreadLocalDataHolder.java +++ b/src/com/mingliqiye/utils/data/ThreadLocalDataHolder.java @@ -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; /** diff --git a/src/com/mingliqiye/utils/file/FileUtil.java b/src/com/mingliqiye/utils/file/FileUtil.java index 2f81005..9344a34 100644 --- a/src/com/mingliqiye/utils/file/FileUtil.java +++ b/src/com/mingliqiye/utils/file/FileUtil.java @@ -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; diff --git a/src/com/mingliqiye/utils/functions/Debouncer.java b/src/com/mingliqiye/utils/functions/Debouncer.java index 8458262..6e02bac 100644 --- a/src/com/mingliqiye/utils/functions/Debouncer.java +++ b/src/com/mingliqiye/utils/functions/Debouncer.java @@ -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.*; diff --git a/src/com/mingliqiye/utils/hash/HashUtils.java b/src/com/mingliqiye/utils/hash/HashUtils.java index b16073e..b2121a5 100644 --- a/src/com/mingliqiye/utils/hash/HashUtils.java +++ b/src/com/mingliqiye/utils/hash/HashUtils.java @@ -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; diff --git a/src/com/mingliqiye/utils/http/Response.java b/src/com/mingliqiye/utils/http/Response.java index 172f7a8..8e032d0 100644 --- a/src/com/mingliqiye/utils/http/Response.java +++ b/src/com/mingliqiye/utils/http/Response.java @@ -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; diff --git a/src/com/mingliqiye/utils/jackson/Serializers.java b/src/com/mingliqiye/utils/jackson/Serializers.java index d3bdcec..db81514 100644 --- a/src/com/mingliqiye/utils/jackson/Serializers.java +++ b/src/com/mingliqiye/utils/jackson/Serializers.java @@ -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; diff --git a/src/com/mingliqiye/utils/jna/FieldStructure.java b/src/com/mingliqiye/utils/jna/FieldStructure.java index 096e0ee..dbac2d5 100644 --- a/src/com/mingliqiye/utils/jna/FieldStructure.java +++ b/src/com/mingliqiye/utils/jna/FieldStructure.java @@ -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; diff --git a/src/com/mingliqiye/utils/jna/time/WinKernel32.java b/src/com/mingliqiye/utils/jna/time/WinKernel32.java index ab9a63a..b061642 100644 --- a/src/com/mingliqiye/utils/jna/time/WinKernel32.java +++ b/src/com/mingliqiye/utils/jna/time/WinKernel32.java @@ -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; diff --git a/src/com/mingliqiye/utils/json/JacksonJsonApi.java b/src/com/mingliqiye/utils/json/JacksonJsonApi.java new file mode 100644 index 0000000..f99dd90 --- /dev/null +++ b/src/com/mingliqiye/utils/json/JacksonJsonApi.java @@ -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 泛型参数,表示目标对象类型 + * @return 解析后的对象 + * @throws JsonException 当解析失败时抛出异常 + */ + @Override + public T parse(String json, Class 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 泛型参数,表示目标对象类型 + * @return 解析后的对象 + * @throws JsonException 当解析失败时抛出异常 + */ + @Override + public T parse(String json, JsonTypeReference 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 泛型参数,表示List中元素的类型 + * @return 解析后的List对象 + */ + @Override + public List parseList(String json, Class elementType) { + return parse(json, JsonTypeUtils.listType(elementType)); + } + + /** + * 将JSON字符串解析为指定键值类型的Map + * + * @param json JSON字符串 + * @param keyType Map中键的类型 + * @param valueType Map中值的类型 + * @param 泛型参数,表示Map中键的类型 + * @param 泛型参数,表示Map中值的类型 + * @return 解析后的Map对象 + */ + @Override + public Map parseMap( + String json, + Class keyType, + Class 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 源对象类型 + * @param 目标对象类型 + * @return 转换后的对象 + */ + @Override + public D convert(T source, Class destinationClass) { + return objectMapper.convertValue(source, destinationClass); + } + + /** + * 在不同泛型对象类型之间进行转换 + * + * @param source 源对象 + * @param destinationType 目标对象的泛型类型引用 + * @param 源对象类型 + * @param 目标对象类型 + * @return 转换后的对象 + */ + @Override + public D convert(T source, JsonTypeReference destinationType) { + return objectMapper.convertValue( + source, + objectMapper.constructType(destinationType.getType()) + ); + } +} diff --git a/src/com/mingliqiye/utils/json/JsonApi.java b/src/com/mingliqiye/utils/json/JsonApi.java new file mode 100644 index 0000000..809e8c1 --- /dev/null +++ b/src/com/mingliqiye/utils/json/JsonApi.java @@ -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 泛型参数,表示目标对象的类型 + * @return 解析后的对象实例 + */ + T parse(String json, Class clazz); + + /** + * 将JSON字符串解析为指定泛型类型对象 + * + * @param json 待解析的JSON字符串 + * @param type 目标对象的Type类型(支持泛型) + * @param 泛型参数,表示目标对象的类型 + * @return 解析后的对象实例 + */ + T parse(String json, JsonTypeReference type); + + /** + * 将对象格式化为JSON字符串 + * + * @param object 待格式化的对象 + * @return 格式化后的JSON字符串 + */ + String format(Object object); + + /** + * 将字节数组形式的JSON解析为指定类型的对象 + * + * @param json 待解析的JSON字节数组 + * @param clazz 目标对象的Class类型 + * @param 泛型参数,表示目标对象的类型 + * @return 解析后的对象实例 + */ + default T parse(byte[] json, Class clazz) { + return parse(new String(json), clazz); + } + + /** + * 将字节数组形式的JSON解析为指定泛型类型对象 + * + * @param json 待解析的JSON字节数组 + * @param type 目标对象的Type类型(支持泛型) + * @param 泛型参数,表示目标对象的类型 + * @return 解析后的对象实例 + */ + default T parse(byte[] json, JsonTypeReference type) { + return parse(new String(json), type); + } + + /** + * 将JSON字符串解析为指定类型的对象,解析失败时返回默认值 + * + * @param json 待解析的JSON字符串 + * @param clazz 目标对象的Class类型 + * @param defaultValue 解析失败时返回的默认值 + * @param 泛型参数,表示目标对象的类型 + * @return 解析后的对象实例或默认值 + */ + default T parse(String json, Class clazz, T defaultValue) { + try { + return parse(json, clazz); + } catch (Exception e) { + return defaultValue; + } + } + + /** + * 将JSON字符串解析为指定泛型类型对象,解析失败时返回默认值 + * + * @param json 待解析的JSON字符串 + * @param type 目标对象的Type类型(支持泛型) + * @param defaultValue 解析失败时返回的默认值 + * @param 泛型参数,表示目标对象的类型 + * @return 解析后的对象实例或默认值 + */ + default T parse( + String json, + JsonTypeReference 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 泛型参数,表示List中元素的类型 + * @return 解析后的List集合 + */ + default List parseList(String json, Class elementType) { + return parse(json, JsonTypeUtils.listType(elementType)); + } + + /** + * 将JSON字符串解析为指定键值类型的Map集合 + * + * @param json 待解析的JSON字符串 + * @param keyType Map中键的类型 + * @param valueType Map中值的类型 + * @param 泛型参数,表示Map中键的类型 + * @param 泛型参数,表示Map中值的类型 + * @return 解析后的Map集合 + */ + default Map parseMap( + String json, + Class keyType, + Class valueType + ) { + JsonTypeReference> mapType = new JsonTypeReference< + Map + >() {}; + 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); + + D convert(T source, Class destinationClass); + D convert(T source, JsonTypeReference destinationType); +} diff --git a/src/com/mingliqiye/utils/json/JsonException.java b/src/com/mingliqiye/utils/json/JsonException.java new file mode 100644 index 0000000..be1b16c --- /dev/null +++ b/src/com/mingliqiye/utils/json/JsonException.java @@ -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); + } +} diff --git a/src/com/mingliqiye/utils/json/JsonTypeReference.java b/src/com/mingliqiye/utils/json/JsonTypeReference.java new file mode 100644 index 0000000..2aa1105 --- /dev/null +++ b/src/com/mingliqiye/utils/json/JsonTypeReference.java @@ -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 引用的泛型类型 + */ +@Getter +public abstract class JsonTypeReference + implements Comparable> { + + protected final Type type; + + /** + * 构造函数,通过反射获取泛型类型信息 + * 仅供内部匿名子类使用 + */ + protected JsonTypeReference() { + Type superClass = getClass().getGenericSuperclass(); + + // 检查是否为匿名子类,防止直接实例化导致无法获取泛型信息 + if (superClass instanceof Class) { + throw new IllegalArgumentException( + "必须使用匿名子类方式创建 JsonTypeReference," + + "例如: new JsonTypeReference>() {}" + ); + } + + this.type = + ((ParameterizedType) superClass).getActualTypeArguments()[0]; + } + + /** + * 构造函数,直接指定类型 + * @param type 具体的类型信息 + */ + protected JsonTypeReference(Type type) { + this.type = Objects.requireNonNull(type, "Type cannot be null"); + } + + /** + * 创建类型引用实例 + * @param 目标类型 + * @return 类型引用实例 + */ + public static JsonTypeReference of() { + return new JsonTypeReference() {}; + } + + /** + * 根据 Class 创建类型引用 + * @param clazz 目标类 + * @param 目标类型 + * @return 类型引用实例 + */ + public static JsonTypeReference of(Class clazz) { + return new JsonTypeReference(clazz) {}; + } + + /** + * 根据 Type 创建类型引用 + * @param type 目标类型 + * @param 目标类型 + * @return 类型引用实例 + */ + public static JsonTypeReference of(Type type) { + return new JsonTypeReference(type) {}; + } + + /** + * 获取原始类型(去掉泛型参数的类型) + * @return 原始类型 Class + */ + @SuppressWarnings("unchecked") + public Class getRawType() { + Type rawType = type; + + // 如果是参数化类型,则提取原始类型部分 + if (type instanceof ParameterizedType) { + rawType = ((ParameterizedType) type).getRawType(); + } + + if (rawType instanceof Class) { + return (Class) 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 o) { + return this.type.toString().compareTo(o.type.toString()); + } +} diff --git a/src/com/mingliqiye/utils/json/JsonTypeUtils.java b/src/com/mingliqiye/utils/json/JsonTypeUtils.java new file mode 100644 index 0000000..4f94f77 --- /dev/null +++ b/src/com/mingliqiye/utils/json/JsonTypeUtils.java @@ -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 元素类型 + * @return 表示数组类型的 JsonTypeReference 对象 + */ + public static JsonTypeReference arrayType(Class componentType) { + return new JsonTypeReference() { + 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 元素类型 + * @return 表示 List 类型的 JsonTypeReference 对象 + * @throws IllegalArgumentException 如果 componentType 为 null,则抛出异常 + */ + public static JsonTypeReference> listType( + Class componentType + ) { + if (componentType == null) { + throw new IllegalArgumentException("componentType cannot be null"); + } + + return new JsonTypeReference>() { + @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 键类型 + * @param 值类型 + * @return 表示 Map 类型的 JsonTypeReference 对象 + * @throws IllegalArgumentException 如果 keyType 或 valueType 为 null,则抛出异常 + */ + public static JsonTypeReference> MapType( + Class keyType, + Class valueType + ) { + if (keyType == null) { + throw new IllegalArgumentException("keyType cannot be null"); + } + if (valueType == null) { + throw new IllegalArgumentException("valueType cannot be null"); + } + + return new JsonTypeReference>() { + @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()) + ); + } + }; + } + }; + } +} diff --git a/src/com/mingliqiye/utils/minecraft/slp/Description.java b/src/com/mingliqiye/utils/minecraft/slp/Description.java index c7e5b43..43da8d5 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/Description.java +++ b/src/com/mingliqiye/utils/minecraft/slp/Description.java @@ -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; diff --git a/src/com/mingliqiye/utils/minecraft/slp/Extra.java b/src/com/mingliqiye/utils/minecraft/slp/Extra.java index 996910a..a092765 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/Extra.java +++ b/src/com/mingliqiye/utils/minecraft/slp/Extra.java @@ -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; diff --git a/src/com/mingliqiye/utils/minecraft/slp/MinecraftServerStatus.java b/src/com/mingliqiye/utils/minecraft/slp/MinecraftServerStatus.java index fff4fb4..91fbabd 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/MinecraftServerStatus.java +++ b/src/com/mingliqiye/utils/minecraft/slp/MinecraftServerStatus.java @@ -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; diff --git a/src/com/mingliqiye/utils/minecraft/slp/PlayerSample.java b/src/com/mingliqiye/utils/minecraft/slp/PlayerSample.java index dd68be5..2ab141f 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/PlayerSample.java +++ b/src/com/mingliqiye/utils/minecraft/slp/PlayerSample.java @@ -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; diff --git a/src/com/mingliqiye/utils/minecraft/slp/Players.java b/src/com/mingliqiye/utils/minecraft/slp/Players.java index b1911d1..ae1ce45 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/Players.java +++ b/src/com/mingliqiye/utils/minecraft/slp/Players.java @@ -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; diff --git a/src/com/mingliqiye/utils/minecraft/slp/SLP.java b/src/com/mingliqiye/utils/minecraft/slp/SLP.java index 4b054d7..64e0adf 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/SLP.java +++ b/src/com/mingliqiye/utils/minecraft/slp/SLP.java @@ -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; diff --git a/src/com/mingliqiye/utils/minecraft/slp/Version.java b/src/com/mingliqiye/utils/minecraft/slp/Version.java index 1002063..ec3ec1a 100644 --- a/src/com/mingliqiye/utils/minecraft/slp/Version.java +++ b/src/com/mingliqiye/utils/minecraft/slp/Version.java @@ -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; diff --git a/src/com/mingliqiye/utils/network/NetworkAddress.java b/src/com/mingliqiye/utils/network/NetworkAddress.java index 7b3754b..73b2ff6 100644 --- a/src/com/mingliqiye/utils/network/NetworkAddress.java +++ b/src/com/mingliqiye/utils/network/NetworkAddress.java @@ -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; diff --git a/src/com/mingliqiye/utils/network/NetworkEndpoint.java b/src/com/mingliqiye/utils/network/NetworkEndpoint.java index 5ee7572..6b08195 100644 --- a/src/com/mingliqiye/utils/network/NetworkEndpoint.java +++ b/src/com/mingliqiye/utils/network/NetworkEndpoint.java @@ -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; diff --git a/src/com/mingliqiye/utils/network/NetworkException.java b/src/com/mingliqiye/utils/network/NetworkException.java index c0c5cb4..4def71c 100644 --- a/src/com/mingliqiye/utils/network/NetworkException.java +++ b/src/com/mingliqiye/utils/network/NetworkException.java @@ -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; /** diff --git a/src/com/mingliqiye/utils/network/NetworkPort.java b/src/com/mingliqiye/utils/network/NetworkPort.java index 0ce23dc..49367c5 100644 --- a/src/com/mingliqiye/utils/network/NetworkPort.java +++ b/src/com/mingliqiye/utils/network/NetworkPort.java @@ -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; diff --git a/src/com/mingliqiye/utils/path/OsPath.java b/src/com/mingliqiye/utils/path/OsPath.java index 0a2c020..3e26a5f 100644 --- a/src/com/mingliqiye/utils/path/OsPath.java +++ b/src/com/mingliqiye/utils/path/OsPath.java @@ -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; diff --git a/src/com/mingliqiye/utils/random/RandomBytes.java b/src/com/mingliqiye/utils/random/RandomBytes.java index 3bd3974..17fd556 100644 --- a/src/com/mingliqiye/utils/random/RandomBytes.java +++ b/src/com/mingliqiye/utils/random/RandomBytes.java @@ -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 起始字节值(包含) diff --git a/src/com/mingliqiye/utils/random/RandomInt.java b/src/com/mingliqiye/utils/random/RandomInt.java index ed7245a..e84a642 100644 --- a/src/com/mingliqiye/utils/random/RandomInt.java +++ b/src/com/mingliqiye/utils/random/RandomInt.java @@ -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; diff --git a/src/com/mingliqiye/utils/random/RandomString.java b/src/com/mingliqiye/utils/random/RandomString.java index eb1b778..3e09151 100644 --- a/src/com/mingliqiye/utils/random/RandomString.java +++ b/src/com/mingliqiye/utils/random/RandomString.java @@ -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; /** diff --git a/src/com/mingliqiye/utils/springboot/autoconfigure/AutoConfiguration.java b/src/com/mingliqiye/utils/springboot/autoconfigure/AutoConfiguration.java index f76a04b..73d8d2c 100644 --- a/src/com/mingliqiye/utils/springboot/autoconfigure/AutoConfiguration.java +++ b/src/com/mingliqiye/utils/springboot/autoconfigure/AutoConfiguration.java @@ -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); + } } diff --git a/src/com/mingliqiye/utils/stream/ListStream.java b/src/com/mingliqiye/utils/stream/CStream.java similarity index 89% rename from src/com/mingliqiye/utils/stream/ListStream.java rename to src/com/mingliqiye/utils/stream/CStream.java index 7c39de4..90b6f86 100644 --- a/src/com/mingliqiye/utils/stream/ListStream.java +++ b/src/com/mingliqiye/utils/stream/CStream.java @@ -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 流中元素的类型 */ -public class ListStream implements java.util.stream.Stream { +public class CStream implements java.util.stream.Stream { private final List list; /** - * 构造方法,初始化 ListStream 实例。 + * 构造方法,初始化 CStream 实例。 * - * @param list 用于构造 ListStream 的列表数据,如果为 null 则使用空列表 + * @param list 用于构造 CStream 的列表数据,如果为 null 则使用空列表 */ - private ListStream(List list) { + private CStream(List list) { this.list = list != null ? list : Lists.newArrayList(); } @@ -496,6 +518,12 @@ public class ListStream implements java.util.stream.Stream { return Collectors.toMap(keyMapper, valueMapper, mergeFunction); } + public static Collector> toMap( + @NotNull Function keyMapper + ) { + return Collectors.toMap(keyMapper, CStream::getThis); + } + /** * 创建一个收集器,将元素转换为 Map,指定键冲突合并函数和 Map 工厂。 * @@ -648,43 +676,47 @@ public class ListStream implements java.util.stream.Stream { } /** - * 创建一个包含指定元素的 ListStream。 + * 创建一个包含指定元素的 CStream。 * - * @param ts 可变参数,表示要包含在 ListStream 中的元素 + * @param ts 可变参数,表示要包含在 CStream 中的元素 * @param 元素类型 - * @return 包含指定元素的新 ListStream 实例 + * @return 包含指定元素的新 CStream 实例 */ @SafeVarargs - public static ListStream of(T... ts) { - return new ListStream<>(Lists.newArrayList(ts)); + public static CStream of(T... ts) { + return new CStream<>(Lists.newArrayList(ts)); } /** - * 创建一个包含指定列表元素的 ListStream。 + * 创建一个包含指定列表元素的 CStream。 * - * @param ts 列表,表示要包含在 ListStream 中的元素 + * @param ts 列表,表示要包含在 CStream 中的元素 * @param 元素类型 - * @return 包含指定元素的新 ListStream 实例 + * @return 包含指定元素的新 CStream 实例 */ - public static ListStream of(List ts) { - return new ListStream<>(Lists.newArrayList(ts)); + public static CStream of(Collection ts) { + return new CStream<>(Lists.newArrayList(ts)); + } + + public static T getThis(T t) { + return t; } /** * 根据给定的谓词条件过滤流中的元素。 * * @param predicate 用于测试元素是否应保留的谓词函数 - * @return 包含满足条件元素的新 ListStream 实例 + * @return 包含满足条件元素的新 CStream 实例 */ @Override - public ListStream filter(Predicate predicate) { + public CStream filter(Predicate predicate) { List 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 implements java.util.stream.Stream { * * @param propertyExtractor 属性提取函数 * @param targetValue 目标值 - * @return 包含满足条件元素的新 ListStream 实例 + * @return 包含满足条件元素的新 CStream 实例 */ - public ListStream filter( + public CStream filter( Function propertyExtractor, Object targetValue ) { @@ -704,7 +736,7 @@ public class ListStream implements java.util.stream.Stream { result.add(item); } } - return new ListStream<>(result); + return new CStream<>(result); } /** @@ -712,15 +744,15 @@ public class ListStream implements java.util.stream.Stream { * * @param mapper 映射函数,将元素从类型 T 转换为类型 R * @param 映射后元素的类型 - * @return 包含转换后元素的新 ListStream 实例 + * @return 包含转换后元素的新 CStream 实例 */ @Override - public ListStream map(Function mapper) { + public CStream map(Function mapper) { List 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 implements java.util.stream.Stream { /** * 将流中的每个元素通过映射函数转换为另一个流,并将所有结果流合并为一个流。 * - * @param mapper 映射函数,将元素从类型 T 转换为另一个 ListStream + * @param mapper 映射函数,将元素从类型 T 转换为另一个 CStream * @param 映射后流中元素的类型 - * @return 合并后的 ListStream 实例 + * @return 合并后的 CStream 实例 */ @Override - public ListStream flatMap( + public CStream flatMap( Function< ? super T, ? extends java.util.stream.Stream @@ -795,7 +827,7 @@ public class ListStream implements java.util.stream.Stream { stream.forEach(result::add); } } - return new ListStream<>(result); + return new CStream<>(result); } /** @@ -840,47 +872,47 @@ public class ListStream implements java.util.stream.Stream { /** * 去除流中重复的元素,保持原有顺序。 * - * @return 包含去重后元素的新 ListStream 实例 + * @return 包含去重后元素的新 CStream 实例 */ @Override - public ListStream distinct() { + public CStream distinct() { Set seen = new LinkedHashSet<>(list); - return new ListStream<>(new ArrayList<>(seen)); + return new CStream<>(new ArrayList<>(seen)); } /** * 对流中的元素进行自然排序。 * - * @return 排序后的新 ListStream 实例 + * @return 排序后的新 CStream 实例 */ @Override - public ListStream sorted() { + public CStream sorted() { List sortedList = Lists.newArrayList(list); Collections.sort((List) sortedList); - return new ListStream<>(sortedList); + return new CStream<>(sortedList); } /** * 根据给定的比较器对流中的元素进行排序。 * * @param comparator 用于比较元素的比较器 - * @return 排序后的新 ListStream 实例 + * @return 排序后的新 CStream 实例 */ @Override - public ListStream sorted(Comparator comparator) { + public CStream sorted(Comparator comparator) { List sortedList = Lists.newArrayList(list); sortedList.sort(comparator); - return new ListStream<>(sortedList); + return new CStream<>(sortedList); } /** * 对流中的每个元素执行指定的操作,但不改变流本身。 * * @param action 要对每个元素执行的操作 - * @return 当前 ListStream 实例 + * @return 当前 CStream 实例 */ @Override - public ListStream peek(Consumer action) { + public CStream peek(Consumer action) { for (T item : list) { action.accept(item); } @@ -891,16 +923,16 @@ public class ListStream implements java.util.stream.Stream { * 截取流中前 maxSize 个元素组成新的流。 * * @param maxSize 要截取的最大元素数量 - * @return 截取后的新 ListStream 实例 + * @return 截取后的新 CStream 实例 * @throws IllegalArgumentException 如果 maxSize 为负数 */ @Override - public ListStream limit(long maxSize) { + public CStream 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 limitedList = Lists.newArrayList(); @@ -912,23 +944,23 @@ public class ListStream implements java.util.stream.Stream { 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 skip(long n) { + public CStream 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 skippedList = Lists.newArrayList(); @@ -939,7 +971,7 @@ public class ListStream implements java.util.stream.Stream { } count++; } - return new ListStream<>(skippedList); + return new CStream<>(skippedList); } /** @@ -1071,10 +1103,10 @@ public class ListStream implements java.util.stream.Stream { @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 implements java.util.stream.Stream { * @return 当前流的顺序版本 */ @Override - public @NotNull ListStream sequential() { + public @NotNull CStream sequential() { return this; } @@ -1283,8 +1315,8 @@ public class ListStream implements java.util.stream.Stream { * @return 当前流的并行版本 */ @Override - public @NotNull ListStream parallel() { - return new ListStream<>(list); + public @NotNull CStream parallel() { + return new CStream<>(list); } /** @@ -1293,7 +1325,7 @@ public class ListStream implements java.util.stream.Stream { * @return 当前流的无序版本 */ @Override - public @NotNull ListStream unordered() { + public @NotNull CStream unordered() { return this; } @@ -1301,10 +1333,10 @@ public class ListStream implements java.util.stream.Stream { * 注册一个关闭处理器,在流关闭时执行。 * * @param closeHandler 关闭处理器 - * @return 当前 ListStream 实例 + * @return 当前 CStream 实例 */ @Override - public @NotNull ListStream onClose(@NotNull Runnable closeHandler) { + public @NotNull CStream onClose(@NotNull Runnable closeHandler) { return this; } diff --git a/src/com/mingliqiye/utils/stream/MapStream.java b/src/com/mingliqiye/utils/stream/MapStream.java deleted file mode 100644 index 04c53b2..0000000 --- a/src/com/mingliqiye/utils/stream/MapStream.java +++ /dev/null @@ -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 键类型 - * @param 值类型 - */ -public class MapStream { - - private final List> entries; - - /** - * 构造方法 - * - * @param entries 包含键值对的列表 - */ - private MapStream(List> entries) { - this.entries = entries != null ? entries : Lists.newArrayList(); - } - - /** - * 从Map创建MapStream - * - * @param map 输入Map - * @param 键类型 - * @param 值类型 - * @return MapStream实例 - */ - public static MapStream of(Map map) { - return new MapStream<>(new ArrayList<>(map.entrySet())); - } - - /** - * 从键值对数组创建MapStream - * - * @param entries 键值对数组 - * @param 键类型 - * @param 值类型 - * @return MapStream实例 - */ - @SafeVarargs - public static MapStream of(Map.Entry... entries) { - return new MapStream<>(Lists.newArrayList(entries)); - } - - /** - * 根据键过滤MapStream - * - * @param keyPredicate 键的谓词条件 - * @return 过滤后的MapStream - */ - public MapStream filterByKey(Predicate keyPredicate) { - List> result = Lists.newArrayList(); - for (Map.Entry entry : entries) { - if (keyPredicate.test(entry.getKey())) { - result.add(entry); - } - } - return new MapStream<>(result); - } - - /** - * 根据值过滤MapStream - * - * @param valuePredicate 值的谓词条件 - * @return 过滤后的MapStream - */ - public MapStream filterByValue(Predicate valuePredicate) { - List> result = Lists.newArrayList(); - for (Map.Entry entry : entries) { - if (valuePredicate.test(entry.getValue())) { - result.add(entry); - } - } - return new MapStream<>(result); - } - - /** - * 过滤MapStream - * - * @param predicate 键值对的谓词条件 - * @return 过滤后的MapStream - */ - public MapStream filter(Predicate> predicate) { - List> result = Lists.newArrayList(); - for (Map.Entry entry : entries) { - if (predicate.test(entry)) { - result.add(entry); - } - } - return new MapStream<>(result); - } - - /** - * 转换键 - * - * @param keyMapper 键映射函数 - * @param 新的键类型 - * @return 转换后的MapStream - */ - public MapStream mapKey( - Function keyMapper - ) { - List> result = Lists.newArrayList(); - for (Map.Entry entry : entries) { - R newKey = keyMapper.apply(entry.getKey()); - result.add(new AbstractMap.SimpleEntry<>(newKey, entry.getValue())); - } - return new MapStream<>(result); - } - - /** - * 转换值 - * - * @param valueMapper 值映射函数 - * @param 新的值类型 - * @return 转换后的MapStream - */ - public MapStream mapValue( - Function valueMapper - ) { - List> result = Lists.newArrayList(); - for (Map.Entry entry : entries) { - R newValue = valueMapper.apply(entry.getValue()); - result.add(new AbstractMap.SimpleEntry<>(entry.getKey(), newValue)); - } - return new MapStream<>(result); - } - - /** - * 转换键值对 - * - * @param entryMapper 键值对映射函数 - * @param 新的键类型 - * @param 新的值类型 - * @return 转换后的MapStream - */ - public MapStream map( - Function, Map.Entry> entryMapper - ) { - List> result = Lists.newArrayList(); - for (Map.Entry entry : entries) { - result.add(entryMapper.apply(entry)); - } - return new MapStream<>(result); - } - - /** - * 将键值对流转换为Map - * - * @return 包含所有键值对的Map - */ - public Map toMap() { - Map map = new HashMap<>(); - for (Map.Entry entry : entries) { - map.put(entry.getKey(), entry.getValue()); - } - return map; - } - - /** - * 将键值对流转换为Map,指定Map类型和键冲突时的合并函数 - * - * @param mapSupplier Map工厂函数 - * @param mergeFunction 键冲突合并函数 - * @param Map类型 - * @return 包含所有键值对的Map - */ - public > M toMap( - Supplier mapSupplier, - BinaryOperator mergeFunction - ) { - M map = mapSupplier.get(); - for (Map.Entry entry : entries) { - map.merge(entry.getKey(), entry.getValue(), mergeFunction); - } - return map; - } - - /** - * 对每个键值对执行操作 - * - * @param action 要执行的操作 - */ - public void forEach(BiConsumer action) { - for (Map.Entry entry : entries) { - action.accept(entry.getKey(), entry.getValue()); - } - } - - /** - * 计算键值对数量 - * - * @return 键值对数量 - */ - public long count() { - return entries.size(); - } - - /** - * 获取键的流 - * - * @return 键的流 - */ - public ListStream keys() { - List keys = Lists.newArrayList(); - for (Map.Entry entry : entries) { - keys.add(entry.getKey()); - } - return ListStream.of(keys); - } - - /** - * 获取值的流 - * - * @return 值的流 - */ - public ListStream values() { - List values = Lists.newArrayList(); - for (Map.Entry entry : entries) { - values.add(entry.getValue()); - } - return ListStream.of(values); - } - - /** - * 对键值对进行排序 - * - * @param comparator 比较器 - * @return 排序后的MapStream - */ - public MapStream sorted(Comparator> comparator) { - List> sortedEntries = Lists.newArrayList(entries); - sortedEntries.sort(comparator); - return new MapStream<>(sortedEntries); - } - - /** - * 限制键值对数量 - * - * @param maxSize 最大数量 - * @return 限制后的MapStream - */ - public MapStream limit(long maxSize) { - if (maxSize < 0) { - throw new IllegalArgumentException("maxSize must be non-negative"); - } - if (maxSize == 0) { - return new MapStream<>(Lists.newArrayList()); - } - - List> limitedEntries = Lists.newArrayList(); - long count = 0; - for (Map.Entry entry : entries) { - if (count >= maxSize) { - break; - } - limitedEntries.add(entry); - count++; - } - return new MapStream<>(limitedEntries); - } - - /** - * 跳过指定数量的键值对 - * - * @param n 要跳过的数量 - * @return 跳过后的MapStream - */ - public MapStream skip(long n) { - if (n < 0) { - throw new IllegalArgumentException("n must be non-negative"); - } - if (n == 0) { - return new MapStream<>(Lists.newArrayList(entries)); - } - - List> skippedEntries = Lists.newArrayList(); - long count = 0; - for (Map.Entry 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 entry = entries.get(i); - sb.append(entry.getKey()).append("=").append(entry.getValue()); - if (i != entries.size() - 1) { - sb.append(", "); - } - } - sb.append(")"); - return sb.toString(); - } -} diff --git a/src/com/mingliqiye/utils/string/StringUtil.java b/src/com/mingliqiye/utils/string/StringUtil.java index e4e4e22..365f49a 100644 --- a/src/com/mingliqiye/utils/string/StringUtil.java +++ b/src/com/mingliqiye/utils/string/StringUtil.java @@ -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

String join( String separator, List

list, - P1R1Function fun + P1RFunction fun ) { // 处理空列表情况 if (list == null || list.isEmpty()) { diff --git a/src/com/mingliqiye/utils/system/SystemUtil.java b/src/com/mingliqiye/utils/system/SystemUtil.java index 61ae4d9..5ed0c47 100644 --- a/src/com/mingliqiye/utils/system/SystemUtil.java +++ b/src/com/mingliqiye/utils/system/SystemUtil.java @@ -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; diff --git a/src/com/mingliqiye/utils/time/DateTime.java b/src/com/mingliqiye/utils/time/DateTime.java index 8757f9e..eba0753 100644 --- a/src/com/mingliqiye/utils/time/DateTime.java +++ b/src/com/mingliqiye/utils/time/DateTime.java @@ -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; diff --git a/src/com/mingliqiye/utils/time/DateTimeOffset.java b/src/com/mingliqiye/utils/time/DateTimeOffset.java index 220f904..b7acd54 100644 --- a/src/com/mingliqiye/utils/time/DateTimeOffset.java +++ b/src/com/mingliqiye/utils/time/DateTimeOffset.java @@ -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; diff --git a/src/com/mingliqiye/utils/time/DateTimeUnit.java b/src/com/mingliqiye/utils/time/DateTimeUnit.java index c3dc291..e1f959b 100644 --- a/src/com/mingliqiye/utils/time/DateTimeUnit.java +++ b/src/com/mingliqiye/utils/time/DateTimeUnit.java @@ -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; /** diff --git a/src/com/mingliqiye/utils/time/Formatter.java b/src/com/mingliqiye/utils/time/Formatter.java index b89c452..fd9cb3a 100644 --- a/src/com/mingliqiye/utils/time/Formatter.java +++ b/src/com/mingliqiye/utils/time/Formatter.java @@ -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; diff --git a/src/com/mingliqiye/utils/time/serialization/Jackson.java b/src/com/mingliqiye/utils/time/serialization/Jackson.java index cb0717d..568c849 100644 --- a/src/com/mingliqiye/utils/time/serialization/Jackson.java +++ b/src/com/mingliqiye/utils/time/serialization/Jackson.java @@ -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; diff --git a/src/com/mingliqiye/utils/time/typehandlers/DateTimeTypeHandler.java b/src/com/mingliqiye/utils/time/typehandlers/DateTimeTypeHandler.java index acf3f08..737e5a3 100644 --- a/src/com/mingliqiye/utils/time/typehandlers/DateTimeTypeHandler.java +++ b/src/com/mingliqiye/utils/time/typehandlers/DateTimeTypeHandler.java @@ -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; diff --git a/src/com/mingliqiye/utils/uuid/MysqlUUIDv1.java b/src/com/mingliqiye/utils/uuid/MysqlUUIDv1.java index af7b261..0fb8cbb 100644 --- a/src/com/mingliqiye/utils/uuid/MysqlUUIDv1.java +++ b/src/com/mingliqiye/utils/uuid/MysqlUUIDv1.java @@ -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; diff --git a/src/com/mingliqiye/utils/uuid/UUID.java b/src/com/mingliqiye/utils/uuid/UUID.java index a47b068..67f77ce 100644 --- a/src/com/mingliqiye/utils/uuid/UUID.java +++ b/src/com/mingliqiye/utils/uuid/UUID.java @@ -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; diff --git a/src/com/mingliqiye/utils/uuid/UUIDException.java b/src/com/mingliqiye/utils/uuid/UUIDException.java index e13981c..4e40b64 100644 --- a/src/com/mingliqiye/utils/uuid/UUIDException.java +++ b/src/com/mingliqiye/utils/uuid/UUIDException.java @@ -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 { diff --git a/src/com/mingliqiye/utils/uuid/serialization/Jackson.java b/src/com/mingliqiye/utils/uuid/serialization/Jackson.java index 6099fef..ae323e6 100644 --- a/src/com/mingliqiye/utils/uuid/serialization/Jackson.java +++ b/src/com/mingliqiye/utils/uuid/serialization/Jackson.java @@ -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; diff --git a/src/com/mingliqiye/utils/uuid/typehandlers/UUIDBinaryTypeHandler.java b/src/com/mingliqiye/utils/uuid/typehandlers/UUIDBinaryTypeHandler.java index 1657d94..69bc13e 100644 --- a/src/com/mingliqiye/utils/uuid/typehandlers/UUIDBinaryTypeHandler.java +++ b/src/com/mingliqiye/utils/uuid/typehandlers/UUIDBinaryTypeHandler.java @@ -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; diff --git a/src/com/mingliqiye/utils/uuid/typehandlers/UUIDConverter.java b/src/com/mingliqiye/utils/uuid/typehandlers/UUIDConverter.java index 978424c..12c3eb9 100644 --- a/src/com/mingliqiye/utils/uuid/typehandlers/UUIDConverter.java +++ b/src/com/mingliqiye/utils/uuid/typehandlers/UUIDConverter.java @@ -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; diff --git a/src/com/mingliqiye/utils/uuid/typehandlers/UUIDStringTypeHandler.java b/src/com/mingliqiye/utils/uuid/typehandlers/UUIDStringTypeHandler.java index f7bffa9..4555d5b 100644 --- a/src/com/mingliqiye/utils/uuid/typehandlers/UUIDStringTypeHandler.java +++ b/src/com/mingliqiye/utils/uuid/typehandlers/UUIDStringTypeHandler.java @@ -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; diff --git a/src/com/mingliqiye/utils/version/VersionUtils.java b/src/com/mingliqiye/utils/version/VersionUtils.java index fefa0dc..209d0ae 100644 --- a/src/com/mingliqiye/utils/version/VersionUtils.java +++ b/src/com/mingliqiye/utils/version/VersionUtils.java @@ -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;