希望能支持方法重载,这样有利于同一类功能的方法定义在一起。
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
### 希望能支持方法重载,这样有利于同一类功能的方法直接定义在一起。比如
```
public final class DateFunction {
@QLFunction("date")
public static LocalDate date() {
return LocalDate.now();
}
@QLFunction("date")
public static LocalDate date(final String value) {
if (value == null) {
throw new IllegalArgumentException("date() function value parameter cannot be null");
}
return LocalDate.parse(value);
}
@QLFunction("date")
public static LocalDate date(final String value, final String format) {
if (value == null) {
throw new IllegalArgumentException("date() function parameter value cannot be null");
}
if (format == null) {
throw new IllegalArgumentException("date() function parameter format cannot be null");
}
return LocalDate.parse(value, DateTimeFormatter.ofPattern(format));
}
}
```
### 目前只能通过CustomFunction去间接处理,特别不方便,而且这样函数定义不够简洁。比如现在只能这样去定义
```
/**
* date()
* date(string)
* date(string, format)
*
* @author zxuanhong
* @date 2025-11-11 10:22
* @since
*/
public class DateFunction implements CustomFunction {
@Override
public Object call(final QContext qContext, final Parameters parameters) throws Throwable {
return switch (parameters.size()) {
case 0 -> LocalDate.now();
case 1 -> format(parameters.getValue(0), null);
case 2 -> format(parameters.getValue(0), parameters.getValue(1));
default -> null;
};
}
private LocalDate format(final Object value, final Object format) {
if (format == null) {
return null;
}
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format.toString());
return format(value, formatter);
}
private LocalDate format(final Object value, final DateTimeFormatter formatter) {
if (value == null) {
return null;
}
if (formatter == null) {
return LocalDate.parse(value.toString());
}
return LocalDate.parse(value.toString(), formatter);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the existing CustomFunction path and the @QLFunction examples shown in the issue, then determine how functions with the same name are currently registered and resolved. Done means overloaded definitions such as date(), date(string), and date(string, format) can be grouped under one name without requiring CustomFunction; the issue names no files or tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100