You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/07/11 17:55:39 UTC
[54/77] [abbrv] commons-collections git commit: extract Put, Get,
and IterableGet interfaces from IterableMap such that our Maps,
which all implement IterableMap,
can have their read/write functionality exposed separately.
extract Put, Get, and IterableGet interfaces from IterableMap such that our Maps, which all implement IterableMap, can have their read/write functionality exposed separately.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/collections_jdk5_branch@751890 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/86b30a0e
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/86b30a0e
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/86b30a0e
Branch: refs/heads/collections_jdk5_branch
Commit: 86b30a0eff32757a52b7ea7cf1c58dab92566289
Parents: 7cb8edc
Author: Matthew Jason Benson <mb...@apache.org>
Authored: Mon Mar 9 22:45:37 2009 +0000
Committer: Matthew Jason Benson <mb...@apache.org>
Committed: Mon Mar 9 22:45:37 2009 +0000
----------------------------------------------------------------------
.../org/apache/commons/collections/Get.java | 77 ++++++++++++++++++++
.../apache/commons/collections/IterableGet.java | 49 +++++++++++++
.../apache/commons/collections/IterableMap.java | 22 +-----
.../org/apache/commons/collections/Put.java | 46 ++++++++++++
4 files changed, 173 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/86b30a0e/src/java/org/apache/commons/collections/Get.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/Get.java b/src/java/org/apache/commons/collections/Get.java
new file mode 100644
index 0000000..8447076
--- /dev/null
+++ b/src/java/org/apache/commons/collections/Get.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The "read" subset of the {@link Map} interface.
+ * @since Commons Collections 5
+ * @TODO fix version
+ * @version $Revision$ $Date$
+ * @see Put
+ * @author Matt Benson
+ */
+public interface Get<K, V> {
+
+ /**
+ * @see Map#containsKey(Object)
+ */
+ public boolean containsKey(Object key);
+
+ /**
+ * @see Map#containsValue(Object)
+ */
+ public boolean containsValue(Object value);
+
+ /**
+ * @see Map#entrySet()
+ */
+ public Set<java.util.Map.Entry<K, V>> entrySet();
+
+ /**
+ * @see Map#get(Object)
+ */
+ public V get(Object key);
+
+ /**
+ * @see Map#remove(Object)
+ */
+ public V remove(Object key);
+
+ /**
+ * @see Map#isEmpty()
+ */
+ public boolean isEmpty();
+
+ /**
+ * @see Map#keySet()
+ */
+ public Set<K> keySet();
+
+ /**
+ * @see Map#size()
+ */
+ public int size();
+
+ /**
+ * @see Map#values()
+ */
+ public Collection<V> values();
+}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/86b30a0e/src/java/org/apache/commons/collections/IterableGet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/IterableGet.java b/src/java/org/apache/commons/collections/IterableGet.java
new file mode 100644
index 0000000..0d10d7b
--- /dev/null
+++ b/src/java/org/apache/commons/collections/IterableGet.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections;
+
+import java.util.Map;
+
+/**
+ * The "read" subset of the {@link Map} interface.
+ * @since Commons Collections 5
+ * @TODO fix version
+ * @version $Revision$ $Date$
+ * @see Put
+ * @author Matt Benson
+ */
+public interface IterableGet<K, V> extends Get<K, V> {
+ /**
+ * Obtains a <code>MapIterator</code> over the map.
+ * <p>
+ * A map iterator is an efficient way of iterating over maps.
+ * There is no need to access the entry set or use Map Entry objects.
+ * <pre>
+ * IterableMap<String,Integer> map = new HashedMap<String,Integer>();
+ * MapIterator<String,Integer> it = map.mapIterator();
+ * while (it.hasNext()) {
+ * String key = it.next();
+ * Integer value = it.getValue();
+ * it.setValue(value + 1);
+ * }
+ * </pre>
+ *
+ * @return a map iterator
+ */
+ MapIterator<K, V> mapIterator();
+
+}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/86b30a0e/src/java/org/apache/commons/collections/IterableMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/IterableMap.java b/src/java/org/apache/commons/collections/IterableMap.java
index b4b92e7..91e6256 100644
--- a/src/java/org/apache/commons/collections/IterableMap.java
+++ b/src/java/org/apache/commons/collections/IterableMap.java
@@ -40,25 +40,5 @@ import java.util.Map;
*
* @author Stephen Colebourne
*/
-public interface IterableMap<K, V> extends Map<K, V> {
-
- /**
- * Obtains a <code>MapIterator</code> over the map.
- * <p>
- * A map iterator is an efficient way of iterating over maps.
- * There is no need to access the entry set or use Map Entry objects.
- * <pre>
- * IterableMap<String,Integer> map = new HashedMap<String,Integer>();
- * MapIterator<String,Integer> it = map.mapIterator();
- * while (it.hasNext()) {
- * String key = it.next();
- * Integer value = it.getValue();
- * it.setValue(value + 1);
- * }
- * </pre>
- *
- * @return a map iterator
- */
- MapIterator<K, V> mapIterator();
-
+public interface IterableMap<K, V> extends Map<K, V>, Put<K, V>, IterableGet<K, V> {
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/86b30a0e/src/java/org/apache/commons/collections/Put.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/Put.java b/src/java/org/apache/commons/collections/Put.java
new file mode 100644
index 0000000..ee55a28
--- /dev/null
+++ b/src/java/org/apache/commons/collections/Put.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections;
+
+import java.util.Map;
+
+/**
+ * The "write" subset of the {@link Map} interface.
+ * @since Commons Collections 5
+ * @TODO fix version
+ * @version $Revision$ $Date$
+ * @see Get
+ * @author Matt Benson
+ */
+public interface Put<K, V> {
+
+ /**
+ * @see Map#clear()
+ */
+ public void clear();
+
+ /**
+ * @see Map#put(Object, Object)
+ */
+ public Object put(K key, V value);
+
+ /**
+ * @see Map#putAll(Map)
+ */
+ public void putAll(Map<? extends K, ? extends V> t);
+
+}