]> source.dussan.org Git - archiva.git/commitdiff
use private static inner class
authorOlivier Lamy <olamy@apache.org>
Mon, 14 May 2012 15:08:53 +0000 (15:08 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 14 May 2012 15:08:53 +0000 (15:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1338244 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java

index bd10fa0f966078f05cc474df381115069803f451..61102dea4ac6cae2c01af7c9ffca967b5b4b2be2 100644 (file)
@@ -645,33 +645,12 @@ public class Maven2RepositoryStorage
         File[] files;
         if ( VersionUtil.isSnapshot( projectVersion ) )
         {
-            files = dir.listFiles( new FilenameFilter()
-            {
-                public boolean accept( File dir, String name )
-                {
-                    if ( name.startsWith( artifactId + "-" ) && name.endsWith( ".pom" ) )
-                    {
-                        String v = name.substring( artifactId.length() + 1, name.length() - 4 );
-                        v = VersionUtil.getBaseVersion( v );
-                        if ( v.equals( projectVersion ) )
-                        {
-                            return true;
-                        }
-                    }
-                    return false;
-                }
-            } );
+            files = dir.listFiles( new PomFilenameFilter( artifactId, projectVersion ) );
         }
         else
         {
             final String pomFile = artifactId + "-" + projectVersion + ".pom";
-            files = dir.listFiles( new FilenameFilter()
-            {
-                public boolean accept( File dir, String name )
-                {
-                    return pomFile.equals( name );
-                }
-            } );
+            files = dir.listFiles( new PomFileFilter( pomFile ) );
         }
         if ( files != null && files.length > 0 )
         {
@@ -770,4 +749,47 @@ public class Maven2RepositoryStorage
             return true;
         }
     }
+
+    private static class PomFilenameFilter
+        implements FilenameFilter
+    {
+
+        private final String artifactId, projectVersion;
+
+        private PomFilenameFilter( String artifactId, String projectVersion )
+        {
+            this.artifactId = artifactId;
+            this.projectVersion = projectVersion;
+        }
+
+        public boolean accept( File dir, String name )
+        {
+            if ( name.startsWith( artifactId + "-" ) && name.endsWith( ".pom" ) )
+            {
+                String v = name.substring( artifactId.length() + 1, name.length() - 4 );
+                v = VersionUtil.getBaseVersion( v );
+                if ( v.equals( projectVersion ) )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    private static class PomFileFilter
+        implements FilenameFilter
+    {
+        private final String pomFile;
+
+        private PomFileFilter( String pomFile )
+        {
+            this.pomFile = pomFile;
+        }
+
+        public boolean accept( File dir, String name )
+        {
+            return pomFile.equals( name );
+        }
+    }
 }