commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1204233 - in /commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath: HandlerConfiguration.java LinkedHandlerBuilder.java
Date Sun, 20 Nov 2011 20:26:04 GMT
Author: simonetripodi
Date: Sun Nov 20 20:26:04 2011
New Revision: 1204233

URL: http://svn.apache.org/viewvc?rev=1204233&view=rev
Log:
again on reducing the proliferation of anonymous classes

Modified:
    commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfiguration.java
    commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/LinkedHandlerBuilder.java

Modified: commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfiguration.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfiguration.java?rev=1204233&r1=1204232&r2=1204233&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfiguration.java
(original)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/HandlerConfiguration.java
Sun Nov 20 20:26:04 2011
@@ -72,20 +72,7 @@ public abstract class HandlerConfigurati
             throw new IllegalArgumentException( "Filter must not be null" );
         }
 
-        return new LinkedHandlerBuilder()
-        {
-
-            public void handleWith( final ClassPathEntryHandler entryHandler )
-            {
-                if ( entryHandler == null )
-                {
-                    throw new IllegalArgumentException( "EntryHandler must be specified"
);
-                }
-
-                handlers.add( new ClassPathHandler( filter, entryHandler ) );
-            }
-
-        };
+        return new LinkedHandlerBuilder( filter, handlers );
     }
 
     /**

Modified: commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/LinkedHandlerBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/LinkedHandlerBuilder.java?rev=1204233&r1=1204232&r2=1204233&view=diff
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/LinkedHandlerBuilder.java
(original)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/apache/commons/meiyo/classpath/LinkedHandlerBuilder.java
Sun Nov 20 20:26:04 2011
@@ -1,5 +1,9 @@
 package org.apache.commons.meiyo.classpath;
 
+import java.util.Collection;
+
+import org.apache.commons.meiyo.classpath.filter.Filter;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,15 +27,36 @@ package org.apache.commons.meiyo.classpa
  * Allows users linking one or more {@link ClassPathEntryHandler} to a {@link Matcher},
  * invoking them when the {@link Matcher} pattern matches when scanning the ClassPath.
  */
-public interface LinkedHandlerBuilder
+public final class LinkedHandlerBuilder
 {
 
+    private final Filter filter;
+
+    /**
+     * Configured {@link ClassPathHandler}s storage.
+     */
+    private final Collection<ClassPathHandler> handlers;
+
+    LinkedHandlerBuilder( Filter filter, Collection<ClassPathHandler> handlers )
+    {
+        this.filter = filter;
+        this.handlers = handlers;
+    }
+
     /**
      * Links one or more {@link ClassPathEntryHandler} to the previously configured {@link
Matcher}.
      *
      * @param entryHandler handler has to be invoked when the {@link Matcher} pattern
      *        matches when scanning the ClassPath.
      */
-    void handleWith( ClassPathEntryHandler entryHandler );
+    public void handleWith( ClassPathEntryHandler entryHandler )
+    {
+        if ( entryHandler == null )
+        {
+            throw new IllegalArgumentException( "EntryHandler must be specified" );
+        }
+
+        handlers.add( new ClassPathHandler( filter, entryHandler ) );
+    }
 
 }



Mime
View raw message