Merge pull request 'v0.0.3' (#2) from dev into master
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
37
pom.xml
37
pom.xml
@@ -6,13 +6,13 @@
|
||||
|
||||
<groupId>com.imyeyu.utils</groupId>
|
||||
<artifactId>timi-utils</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -27,10 +27,42 @@
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.20.0</version>
|
||||
<configuration>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.36</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.11.2</version>
|
||||
<configuration>
|
||||
<sourcepath>${project.build.directory}/delombok</sourcepath>
|
||||
<encoding>UTF-8</encoding>
|
||||
<charset>UTF-8</charset>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
@@ -77,7 +109,6 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -82,7 +82,8 @@ public class OS {
|
||||
public static void run(String command) {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] {command});
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.imyeyu.utils;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.CallbackArgReturn;
|
||||
import com.imyeyu.java.ref.Ref;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -31,6 +33,8 @@ public class StringInterpolator {
|
||||
private final Map<String, CallbackArgReturn<String, String>> filterMap = new HashMap<>();
|
||||
|
||||
/** 空值处理策略 */
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean nullable = false;
|
||||
|
||||
public StringInterpolator(String regex) {
|
||||
@@ -150,14 +154,6 @@ public class StringInterpolator {
|
||||
filterMap.clear();
|
||||
}
|
||||
|
||||
public void setNullable(boolean nullable) {
|
||||
this.nullable = nullable;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return nullable;
|
||||
}
|
||||
|
||||
/** 表达式部分内部类 */
|
||||
private record ExpressionParts(String variable, String[] filters) {
|
||||
}
|
||||
|
||||
@@ -67,45 +67,6 @@ public class Text {
|
||||
return String.format("%0" + l + "d", number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰转下划线
|
||||
*
|
||||
* @param camelCaseStr 驼峰字符串
|
||||
* @return 下划线字符串
|
||||
*/
|
||||
public static String camelCase2underscore(String camelCaseStr) {
|
||||
return camelCaseStr.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下划线转驼峰
|
||||
*
|
||||
* @param underscoreName 下划线字符串
|
||||
* @return 驼峰字符串
|
||||
*/
|
||||
public static String underscore2camelCase(String underscoreName) {
|
||||
if (TimiJava.isEmpty(underscoreName)) {
|
||||
return underscoreName;
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < underscoreName.length(); i++) {
|
||||
char c = underscoreName.charAt(i);
|
||||
if ('_' == c) {
|
||||
flag = true;
|
||||
} else {
|
||||
if (flag) {
|
||||
result.append(Character.toUpperCase(c));
|
||||
flag = false;
|
||||
} else {
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 与多个字符串进行与比较
|
||||
*
|
||||
@@ -391,6 +352,44 @@ public class Text {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰转下划线
|
||||
*
|
||||
* @param camelCaseStr 驼峰字符串
|
||||
* @return 下划线字符串
|
||||
*/
|
||||
public static String camelCase2underscore(String camelCaseStr) {
|
||||
return camelCaseStr.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下划线转驼峰
|
||||
*
|
||||
* @param underscoreName 下划线字符串
|
||||
* @return 驼峰字符串
|
||||
*/
|
||||
public static String underscore2camelCase(String underscoreName) {
|
||||
if (TimiJava.isEmpty(underscoreName)) {
|
||||
return underscoreName;
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < underscoreName.length(); i++) {
|
||||
char c = underscoreName.charAt(i);
|
||||
if ('_' == c) {
|
||||
flag = true;
|
||||
} else {
|
||||
if (flag) {
|
||||
result.append(Character.toUpperCase(c));
|
||||
flag = false;
|
||||
} else {
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取驼峰类名
|
||||
*
|
||||
@@ -400,4 +399,8 @@ public class Text {
|
||||
public static String camelCaseClassName(Class<?> clazz) {
|
||||
return Character.toLowerCase(clazz.getSimpleName().charAt(0)) + clazz.getSimpleName().substring(1);
|
||||
}
|
||||
|
||||
public static String underscoreClassName(Class<?> clazz) {
|
||||
return camelCase2underscore(clazz.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.imyeyu.utils;
|
||||
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
@@ -386,77 +387,28 @@ public class Time {
|
||||
* @author 夜雨
|
||||
* @version 2022-10-12 14:46
|
||||
*/
|
||||
@Getter
|
||||
public static class Between {
|
||||
|
||||
/** 年 */
|
||||
int year;
|
||||
|
||||
/** 月 */
|
||||
int month;
|
||||
|
||||
/** 天 */
|
||||
int day;
|
||||
|
||||
/** 小时 */
|
||||
int hour;
|
||||
|
||||
/** 分钟 */
|
||||
int minute;
|
||||
|
||||
/** 秒 */
|
||||
int second;
|
||||
|
||||
/** 毫秒 */
|
||||
int millis;
|
||||
|
||||
/**
|
||||
* 获取年数
|
||||
*
|
||||
* @return 年数
|
||||
*/
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月数
|
||||
*
|
||||
* @return 月数
|
||||
*/
|
||||
public int getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天数
|
||||
*
|
||||
* @return 天数
|
||||
*/
|
||||
public int getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小时
|
||||
*
|
||||
* @return 小时
|
||||
*/
|
||||
public int getHour() {
|
||||
return hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分钟
|
||||
*
|
||||
* @return 分钟
|
||||
*/
|
||||
public int getMinute() {
|
||||
return minute;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取秒
|
||||
*
|
||||
* @return 秒
|
||||
*/
|
||||
public int getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取毫秒
|
||||
*
|
||||
* @return 毫秒
|
||||
*/
|
||||
public int getMillis() {
|
||||
return millis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user