Remove possibility of passing null to constructors of ReadOnly* classes
authorMaciej Piechotka <uzytkownik2@gmail.com>
Sun, 6 Sep 2009 22:47:57 +0000 (00:47 +0200)
committerDidier 'Ptitjes <ptitjes@free.fr>
Sun, 6 Sep 2009 23:10:25 +0000 (01:10 +0200)
Fixes bug 590305.

gee/readonlycollection.vala
gee/readonlylist.vala
gee/readonlymap.vala
gee/readonlyset.vala

index fb99885..c4ad4d8 100644 (file)
@@ -53,9 +53,9 @@ public class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
         * Constructs a read-only collection that mirrors the content of the
         * specified collection.
         *
-        * @param collection the collection to decorate (may be null).
+        * @param collection the collection to decorate.
         */
-       public ReadOnlyCollection (Collection<G>? collection = null) {
+       public ReadOnlyCollection (Collection<G> collection) {
                this._collection = collection;
        }
 
@@ -70,10 +70,6 @@ public class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
         * @inheritDoc
         */
        public Gee.Iterator<G> iterator () {
-               if (_collection == null) {
-                       return new Iterator<G> ();
-               }
-
                return _collection.iterator ();
        }
 
@@ -81,10 +77,6 @@ public class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
         * @inheritDoc
         */
        public bool contains (G item) {
-               if (_collection == null) {
-                       return false;
-               }
-
                return _collection.contains (item);
        }
 
@@ -120,12 +112,7 @@ public class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
         * @inheritDoc
         */
        public bool contains_all (Collection<G> collection) {
-               foreach (G element in collection) {
-                       if (!contains (element)) {
-                               return false;
-                       }
-               }
-               return true;
+               return _collection.contains_all (collection);
        }
 
        /**
index 7412bf8..fd712d3 100644 (file)
@@ -37,9 +37,9 @@ public class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
         * Constructs a read-only list that mirrors the content of the specified
         * list.
         *
-        * @param list the list to decorate (may be null).
+        * @param list the list to decorate.
         */
-       public ReadOnlyList (List<G>? list = null) {
+       public ReadOnlyList (List<G> list) {
                base (list);
        }
 
@@ -47,10 +47,6 @@ public class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
         * @inheritDoc
         */
        public int index_of (G item) {
-               if (_collection == null) {
-                       return -1;
-               }
-
                return ((Gee.List<G>) _collection).index_of (item);
        }
 
@@ -72,10 +68,6 @@ public class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
         * @inheritDoc
         */
        public new G? get (int index) {
-               if (_collection == null) {
-                       return null;
-               }
-
                return ((Gee.List<G>) _collection).get (index);
        }
 
@@ -97,10 +89,6 @@ public class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
         * @inheritDoc
         */
        public G? first () {
-               if (_collection == null) {
-                       return null;
-               }
-
                return ((Gee.List<G>) _collection).first ();
        }
 
@@ -108,10 +96,6 @@ public class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
         * @inheritDoc
         */
        public G? last () {
-               if (_collection == null) {
-                       return null;
-               }
-
                return ((Gee.List<G>) _collection).last ();
        }
 
index 9b91365..3166104 100644 (file)
@@ -52,9 +52,9 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
        /**
         * Constructs a read-only map that mirrors the content of the specified map.
         *
-        * @param map the map to decorate (may be null).
+        * @param map the map to decorate.
         */
-       public ReadOnlyMap (Map<K,V>? map = null) {
+       public ReadOnlyMap (Map<K,V> map) {
                this._map = map;
        }
 
@@ -62,10 +62,6 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
         * @inheritDoc
         */
        public Set<K> get_keys () {
-               if (_map == null) {
-                       return new ReadOnlySet<K> ();
-               }
-
                return _map.get_keys ();
        }
 
@@ -73,10 +69,6 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
         * @inheritDoc
         */
        public Collection<V> get_values () {
-               if (_map == null) {
-                       return new ReadOnlyCollection<V> ();
-               }
-
                return _map.get_values ();
        }
 
@@ -84,10 +76,6 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
         * @inheritDoc
         */
        public bool contains (K key) {
-               if (_map == null) {
-                       return false;
-               }
-
                return _map.contains (key);
        }
 
@@ -95,10 +83,6 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
         * @inheritDoc
         */
        public new V? get (K key) {
-               if (_map == null) {
-                       return null;
-               }
-
                return _map.get (key);
        }
 
@@ -141,10 +125,6 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
         * @inheritDoc
         */
        public bool contains_all (Map<K,V> map) {
-               if (_map == null) {
-                       return false;
-               }
-
                return _map.contains_all (map);
        }
 }
index 6bd5f72..3997409 100644 (file)
@@ -38,7 +38,7 @@ public class Gee.ReadOnlySet<G> : Gee.ReadOnlyCollection<G>, Set<G> {
         *
         * @param set the set to decorate.
         */
-       public ReadOnlySet (Set<G>? set = null) {
+       public ReadOnlySet (Set<G> set) {
                base(set);
        }
 }