hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1407783 - in /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config: Lookup.java Registry.java
Date Sat, 10 Nov 2012 11:57:00 GMT
Author: olegk
Date: Sat Nov 10 11:57:00 2012
New Revision: 1407783

URL: http://svn.apache.org/viewvc?rev=1407783&view=rev
Log:
Registry to implement a generic Lookup interface

Added:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Lookup.java
      - copied, changed from r1407244, httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java
Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java

Copied: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Lookup.java
(from r1407244, httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Lookup.java?p2=httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Lookup.java&p1=httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java&r1=1407244&r2=1407783&rev=1407783&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Lookup.java
Sat Nov 10 11:57:00 2012
@@ -27,61 +27,14 @@
 
 package org.apache.http.config;
 
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.util.Args;
 
 /**
- * Generic registry of items keyed by low-case string ID.
+ * Generic lookup by low-case string ID.
  *
  * @since 4.3
  */
-@ThreadSafe
-public final class Registry<I> {
-
-    private final Map<String, I> map;
-
-    public static class Builder<I> {
-
-        final Map<String, I> items;
-
-        public Builder() {
-            super();
-            this.items = new HashMap<String, I>();
-        }
-
-        public Builder<I> register(final String id, final I item) {
-            Args.notEmpty(id, "ID");
-            Args.notNull(item, "Item");
-            items.put(id.toLowerCase(Locale.US), item);
-            return this;
-        }
-
-        public Registry<I> build() {
-            return new Registry<I>(items);
-        }
-
-    }
-
-    Registry(final Map<String, I> map) {
-        super();
-        this.map = new ConcurrentHashMap<String, I>(map);
-    }
-
-    public I lookup(final String key) {
-        if (key == null) {
-            return null;
-        }
-        return map.get(key.toLowerCase(Locale.US));
-    }
+public interface Lookup<I> {
 
-    @Override
-    public String toString() {
-        return map.toString();
-    }
+    I lookup(String name);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java?rev=1407783&r1=1407782&r2=1407783&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/Registry.java
Sat Nov 10 11:57:00 2012
@@ -41,7 +41,7 @@ import org.apache.http.util.Args;
  * @since 4.3
  */
 @ThreadSafe
-public final class Registry<I> {
+public final class Registry<I> implements Lookup<I> {
 
     private final Map<String, I> map;
 



Mime
View raw message