|
@@ -12,6 +12,7 @@ import org.apache.ibatis.reflection.property.PropertyNamer;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
+@SuppressWarnings("UnusedReturnValue")
|
|
|
@AllArgsConstructor
|
|
|
public class Fields<T> {
|
|
|
|
|
@@ -23,16 +24,32 @@ public class Fields<T> {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public <S, V> Fields<T> select(SFunction<S, V> function, SFunction<T, ?> asFunction) {
|
|
|
- String as = PropertyNamer.methodToProperty(LambdaUtils.extract(asFunction).getImplMethodName());
|
|
|
+ public <S, V> Fields<T> select(String alias, SFunction<S, V> function) {
|
|
|
LambdaMeta meta = LambdaUtils.extract(function);
|
|
|
- sql.fieldList.add(FieldUtil.getSqlFieldName(sql.getTableAlias(meta), meta) + StringPool.SPACE + as);
|
|
|
+ sql.fieldList.add(FieldUtil.getSqlFieldName(alias, meta));
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public <S, V> Fields<T> select(String alias, SFunction<S, V> function) {
|
|
|
+ @SafeVarargs
|
|
|
+ public final <S, V> Fields<T> select(SFunction<S, V>... functions) {
|
|
|
+ for (SFunction<S, V> function : functions) {
|
|
|
+ select(function);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SafeVarargs
|
|
|
+ public final <S, V> Fields<T> select(String alias, SFunction<S, V>... functions) {
|
|
|
+ for (SFunction<S, V> function : functions) {
|
|
|
+ select(alias, function);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public <S, V> Fields<T> select(SFunction<S, V> function, SFunction<T, ?> asFunction) {
|
|
|
+ String as = PropertyNamer.methodToProperty(LambdaUtils.extract(asFunction).getImplMethodName());
|
|
|
LambdaMeta meta = LambdaUtils.extract(function);
|
|
|
- sql.fieldList.add(FieldUtil.getSqlFieldName(alias, meta));
|
|
|
+ sql.fieldList.add(FieldUtil.getSqlFieldName(sql.getTableAlias(meta), meta) + StringPool.SPACE + as);
|
|
|
return this;
|
|
|
}
|
|
|
|