MCPcopy Index your code
hub / github.com/duanluan/zutil

github.com/duanluan/zutil @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,589 symbols 6,461 edges 171 files 748 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ZUtil

GitHub commits

English | 简体中文

A faster and more comprehensive Java utility library.

For usage, please refer to the documentation and javadoc.

For performance comparison with Hutool, see jmh.comparison.

Features

Stargazers over time

Stargazers over time

Instructions

Installation

Maven

<dependency>
  <groupId>top.csaf</groupId>
  <artifactId>zutil-all</artifactId>
  <version>2.0.0</version>
</dependency>

Gradle

// groovy
implementation 'top.csaf:zutil-all:2.0.0'
// kotlin
implementation("top.csaf:zutil-all:2.0.0")

Notes on Installation

This library includes slf4j-api and slf4j-simple, which conflict with spring-boot-starter-web. You need to exclude them manually.

Maven


<dependency>
  <groupId>top.csaf</groupId>
  <artifactId>zutil-all</artifactId>
   <version>2.0.0</version>
  <exclusions>
    <exclusion>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
    </exclusion>
  </exclusions>
</dependency>


<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Gradle

Reference: Excluding transitive dependencies - Gradle User Manual

// groovy
dependencies {
  // Option 1: Exclude slf4j from ZUtil
  implementation('top.csaf:zutil-all:2.0.0') {
    exclude group: 'org.slf4j', module: 'slf4j-api'
    exclude group: 'org.slf4j', module: 'slf4j-simple'
  }
  // Option 2: Exclude Logback from spring-boot-starter-web
  implementation('org.springframework.boot:spring-boot-starter-web') {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
  }
}

// kotlin
dependencies {
  // Option 1: Exclude slf4j from ZUtil
  implementation("top.csaf:zutil-all:2.0.0") {
    exclude(group = "org.slf4j", module = "slf4j-api")
    exclude(group = "org.slf4j", module = "slf4j-simple")
  }
  // Option 2: Exclude Logback from spring-boot-starter-web
  implementation("org.springframework.boot:spring-boot-starter-web") {
    exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
  }
}

JMH Benchmark Explanation

// Benchmark                                                 Mode     Cnt    Score    Error   Units
// ToPinyinTest.toPinyinByHutool                            thrpt       5    2.880 ±  0.160  ops/us
// ToPinyinTest.toPinyinByZUtil                             thrpt       5    4.577 ±  0.133  ops/us
// ToPinyinTest.toPinyinByHutool                             avgt       5    0.356 ±  0.012   us/op
// ToPinyinTest.toPinyinByZUtil                              avgt       5    0.216 ±  0.006   us/op
// ToPinyinTest.toPinyinByHutool                           sample  175058    0.435 ±  0.008   us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.00    sample            0.300            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.50    sample            0.400            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.90    sample            0.500            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.95    sample            0.500            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.99    sample            0.900            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.999   sample            1.600            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p0.9999  sample           40.900            us/op
// ToPinyinTest.toPinyinByHutool:toPinyinByHutool·p1.00    sample          277.504            us/op
// ToPinyinTest.toPinyinByZUtil                            sample  162384    0.393 ±  0.008   us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.00      sample            0.200            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.50      sample            0.300            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.90      sample            0.500            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.95      sample            0.600            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.99      sample            1.000            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.999     sample            2.500            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p0.9999    sample           45.425            us/op
// ToPinyinTest.toPinyinByZUtil:toPinyinByZUtil·p1.00      sample          170.496            us/op
// ToPinyinTest.toPinyinByHutool                               ss       5   30.880 ± 37.754   us/op
// ToPinyinTest.toPinyinByZUtil                                ss       5   23.060 ± 16.885   us/op

Mode (org.openjdk.jmh.annotations.Mode): - thrpt: Throughput (ops/time). Higher is better. - avgt: Average time (time/op). Lower is better. - sample: Sampling time. Lower is better. - ss: Single shot invocation time. Lower is better.

Contributing

  1. Fork and Clone the repo.
  2. Contribution types:
    • New classes or methods: please discuss first in the Discord or QQ group.
    • Bug fixes (fix), performance improvements (perf), or tests (test).
  3. Testing:

    • Use org.junit.jupiter.api.Assertions for code coverage testing:

    ```java …… import top.csaf.id.NanoIdUtil; import static org.junit.jupiter.api.Assertions.*;

    @Slf4j @DisplayName("NanoId Utility Class Test") class NanoIdUtilTest {

    @DisplayName("Generate NanoID")
    @Test
    void randomNanoId() {
      /** {@link NanoIdUtil#randomNanoId(int, char[], java.util.Random) } */
      assertThrows(NullPointerException.class, () -> NanoIdUtils.randomNanoId(0, (char[]) null, NanoIdUtils.DEFAULT_ID_GENERATOR));
      assertThrows(NullPointerException.class, () -> NanoIdUtils.randomNanoId(0, new char[0], null));
      assertThrows(IllegalArgumentException.class, () -> NanoIdUtils.randomNanoId(0, new char[0], NanoIdUtils.DEFAULT_ID_GENERATOR));
      assertThrows(IllegalArgumentException.class, () -> NanoIdUtils.randomNanoId(1, new char[0], NanoIdUtils.DEFAULT_ID_GENERATOR));
      assertThrows(IllegalArgumentException.class, () -> NanoIdUtils.randomNanoId(1, new char[256], NanoIdUtils.DEFAULT_ID_GENERATOR));
      assertDoesNotThrow(() -> NanoIdUtils.randomNanoId(NanoIdUtils.DEFAULT_SIZE, NanoIdUtils.DEFAULT_ALPHABET, NanoIdUtils.DEFAULT_ID_GENERATOR));
    }
    

    } `` - Navigate to the **project root directory**, then run the following command to test (usingReactorto build dependencies automatically):mvn test -pl -am -Dtest= "-Dsurefire.failIfNoSpecifiedTests=false"(e.g.,mvn test -pl zutil-all -am -Dtest=NanoIdUtilTest "-Dsurefire.failIfNoSpecifiedTests=false"). - Runmvn jacoco:reportto generate the code coverage report in thetarget/sitedirectory. - Ensure coverage of updated classes or methods is above **90%** before submitting. - Parameter validation usinglombok.NonNull` can be ignored. 4. Please read and follow the Commit Convention (based on Angular guidelines) to ensure the bilingual format is correct, then create a pull request.

Extension points exported contracts — how you extend this code

RegionSearcher (Interface)
ip2region 搜索器接口。 [2 implementers]
zutil-http/src/main/java/top/csaf/ip/IpUtil.java
PropFunc (Interface)
属性 Function @param 输入类型 @param 输出类型
zutil-all/src/main/java/top/csaf/bean/PropFunc.java

Core symbols most depended-on inside this repo

put
called by 161
zutil-all/src/main/java/top/csaf/tree/TreeNode.java
contains
called by 139
zutil-core/src/main/java/top/csaf/coll/CollUtil.java
format
called by 98
zutil-date/src/main/java/top/csaf/date/DateUtil.java
toString
called by 89
zutil-core/src/main/java/top/csaf/lang/ArrayUtil.java
size
called by 87
zutil-core/src/main/java/top/csaf/coll/MapUtil.java
removeAllElements
called by 84
zutil-core/src/main/java/top/csaf/lang/ArrayUtil.java
get
called by 78
zutil-http/src/main/java/top/csaf/http/HttpUtil.java
get
called by 76
zutil-date/src/main/java/top/csaf/date/DateFeat.java

Shape

Method 1,380
Class 193
Enum 7
Interface 5
Function 4

Languages

Java100%
TypeScript1%

Modules by API surface

zutil-io/src/main/java/top/csaf/io/CompressUtil.java70 symbols
zutil-http/src/main/java/top/csaf/ip/IpUtil.java60 symbols
zutil-core/src/main/java/top/csaf/coll/CollUtil.java57 symbols
zutil-io/src/test/java/top/csaf/junit/CompressUtilTest.java53 symbols
zutil-date/src/main/java/top/csaf/date/DateUtil.java53 symbols
zutil-core/src/main/java/top/csaf/coll/MapUtil.java52 symbols
zutil-http/src/main/java/top/csaf/http/convert/AutoJsonMsgConvertor.java49 symbols
zutil-all/src/test/java/top/csaf/junit/RemainingCoverageTest.java40 symbols
zutil-http/src/test/java/top/csaf/http/UrlUtilTest.java32 symbols
zutil-http/src/test/java/top/csaf/ip/IpUtilTest.java31 symbols
zutil-regex/src/main/java/top/csaf/regex/RegExUtil.java30 symbols
zutil-all/src/test/java/top/csaf/jmh/base/array/ArrayDeduplicateTest.java28 symbols

For agents

$ claude mcp add zutil \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact