1. Stepan Koltsov
  2. bolts

Commits

Stepan Koltsov  committed 3af1fce

CollectionsF.wrap(array) method

  • Participants
  • Parent commits cda07f7
  • Branches trunk
  • Tags 1.0.1

Comments (0)

Files changed (1)

File src/main/java/ru/yandex/bolts/collection/CollectionsF.java

View file
 package ru.yandex.bolts.collection;
 
+import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
-import java.io.Serializable;
 
 import ru.yandex.bolts.collection.impl.AbstractListF;
 import ru.yandex.bolts.collection.impl.AbstractSetF;
     public static MapF<String, String> wrap(Properties ps) {
         return x(ps);
     }
+    
+    /**
+     * Wrap array.
+     * 
+     * @see #x(Object[])
+     */
+    public static <E> ListF<E> wrap(E[] array) {
+        return x(array);
+    }
 
     /** Wrap iterator */
     public static <E> IteratorF<E> x(Iterator<E> iterator) {
         return x((Map) properties);
     }
     
+    /**
+     * Wrap array.
+     * 
+     * @see Arrays#asList(Object...)
+     * @see #list(Object...)
+     */
+    public static <E> ListF<E> x(E[] array) {
+        return x(Arrays.asList(array));
+    }
+    
     
     /** Empty set */
     @SuppressWarnings({"unchecked"})
     }
 
     /**
-     * Create list of specified elements. Resulting list is immutable, however changing array could lead to changing result list.
+     * Create list of specified elements.
+     * 
+     * The resulting list is immutable, however changing array may cause changing the resulting list.
+     * 
+     * @see #wrap(Object[]) for real array wrapping
      */
     public static <E> ListF<E> list(E... elements) {
         if (elements.length == 0) return list();