zhouhao 7 лет назад
Родитель
Сommit
dfbcfc5c19

+ 12 - 1
hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/Lists.java

@@ -5,6 +5,12 @@ import java.util.function.Supplier;
 
 
 /**
 /**
  * List工具,用于构建list等操作
  * List工具,用于构建list等操作
+ * <pre>
+ *     Lists.buildList("1","2")
+ *     .add("3")
+ *     .add("4","5","6")
+ *     .get();
+ * </pre>
  *
  *
  * @author zhouhao
  * @author zhouhao
  */
  */
@@ -30,11 +36,15 @@ public class Lists {
             this.target = target;
             this.target = target;
         }
         }
 
 
-        public ListBuilder<V> add(V value) {
+        public ListBuilder<V> add(V value, V... more) {
             this.target.add(value);
             this.target.add(value);
+            if (more.length > 0) {
+                addAll(Arrays.asList(more));
+            }
             return this;
             return this;
         }
         }
 
 
+
         public ListBuilder<V> addAll(Collection<V> value) {
         public ListBuilder<V> addAll(Collection<V> value) {
             this.target.addAll(value);
             this.target.addAll(value);
             return this;
             return this;
@@ -45,4 +55,5 @@ public class Lists {
         }
         }
 
 
     }
     }
+
 }
 }