Author: mattsicker
Date: Mon May 26 23:40:40 2014
New Revision: 1597665
URL: http://svn.apache.org/r1597665
Log:
Remove unused methods and inner classes.
- Amusingly, this code duplicates a lot of stuff from Hamcrest.
- Code looks like it used to be used with annotation processing.
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java?rev=1597665&r1=1597664&r2=1597665&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
Mon May 26 23:40:40 2014
@@ -21,7 +21,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.lang.annotation.Annotation;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
@@ -132,73 +131,6 @@ public class ResolverUtil {
public void setClassLoader(final ClassLoader classloader) {
this.classloader = classloader; }
/**
- * Attempts to discover classes that are assignable to the type provided.
In the case
- * that an interface is provided this method will collect implementations.
In the case
- * of a non-interface class, subclasses will be collected. Accumulated
classes can be
- * accessed by calling {@link #getClasses()}.
- *
- * @param parent the class of interface to find subclasses or
implementations of
- * @param packageNames one or more package names to scan (including
subpackages) for classes
- */
- public void findImplementations(final Class<?> parent, final String...
packageNames) {
- if (packageNames == null) {
- return;
- }
-
- final Test test = new IsA(parent);
- for (final String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
- * Attempts to discover classes who's name ends with the provided suffix.
Accumulated classes can be
- * accessed by calling {@link #getClasses()}.
- *
- * @param suffix The class name suffix to match
- * @param packageNames one or more package names to scan (including
subpackages) for classes
- */
- public void findSuffix(final String suffix, final String... packageNames) {
- if (packageNames == null) {
- return;
- }
-
- final Test test = new NameEndsWith(suffix);
- for (final String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
- * Attempts to discover classes that are annotated with to the annotation.
Accumulated
- * classes can be accessed by calling {@link #getClasses()}.
- *
- * @param annotation the annotation that should be present on matching
classes
- * @param packageNames one or more package names to scan (including
subpackages) for classes
- */
- public void findAnnotated(final Class<? extends Annotation> annotation,
final String... packageNames) {
- if (packageNames == null) {
- return;
- }
-
- final Test test = new AnnotatedWith(annotation);
- for (final String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- public void findNamedResource(final String name, final String...
pathNames) {
- if (pathNames == null) {
- return;
- }
-
- final Test test = new NameIs(name);
- for (final String pkg : pathNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
* Attempts to discover classes that pass the test. Accumulated
* classes can be accessed by calling {@link #getClasses()}.
*
@@ -480,149 +412,4 @@ public class ResolverUtil {
boolean doesMatchResource();
}
- /**
- * Test against a Class.
- */
- public abstract static class ClassTest implements Test {
- @Override
- public boolean matches(final URI resource) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean doesMatchClass() {
- return true;
- }
-
- @Override
- public boolean doesMatchResource() {
- return false;
- }
- }
-
- /**
- * Test against a resource.
- */
- public abstract static class ResourceTest implements Test {
- @Override
- public boolean matches(final Class<?> cls) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean doesMatchClass() {
- return false;
- }
-
- @Override
- public boolean doesMatchResource() {
- return true;
- }
- }
-
- /**
- * A Test that checks to see if each class is assignable to the provided
class. Note
- * that this test will match the parent type itself if it is presented for
matching.
- */
- public static class IsA extends ClassTest {
- private final Class<?> parent;
-
- /**
- * Constructs an IsA test using the supplied Class as the parent
class/interface.
- * @param parentType The parent class to check for.
- */
- public IsA(final Class<?> parentType) { this.parent = parentType; }
-
- /**
- * Returns true if type is assignable to the parent type supplied in
the constructor.
- * @param type The Class to check.
- * @return true if the Class matches.
- */
- @Override
- public boolean matches(final Class<?> type) {
- return type != null && parent.isAssignableFrom(type);
- }
-
- @Override
- public String toString() {
- return "is assignable to " + parent.getSimpleName();
- }
- }
-
- /**
- * A Test that checks to see if each class name ends with the provided
suffix.
- */
- public static class NameEndsWith extends ClassTest {
- private final String suffix;
-
- /**
- * Constructs a NameEndsWith test using the supplied suffix.
- * @param suffix the String suffix to check for.
- */
- public NameEndsWith(final String suffix) { this.suffix = suffix; }
-
- /**
- * Returns true if type name ends with the suffix supplied in the
constructor.
- * @param type The Class to check.
- * @return true if the Class matches.
- */
- @Override
- public boolean matches(final Class<?> type) {
- return type != null && type.getName().endsWith(suffix);
- }
-
- @Override
- public String toString() {
- return "ends with the suffix " + suffix;
- }
- }
-
- /**
- * A Test that checks to see if each class is annotated with a specific
annotation. If it
- * is, then the test returns true, otherwise false.
- */
- public static class AnnotatedWith extends ClassTest {
- private final Class<? extends Annotation> annotation;
-
- /**
- * Constructs an AnnotatedWith test for the specified annotation type.
- * @param annotation The annotation to check for.
- */
- public AnnotatedWith(final Class<? extends Annotation> annotation) {
- this.annotation = annotation;
- }
-
- /**
- * Returns true if the type is annotated with the class provided to
the constructor.
- * @param type the Class to match against.
- * @return true if the Classes match.
- */
- @Override
- public boolean matches(final Class<?> type) {
- return type != null && type.isAnnotationPresent(annotation);
- }
-
- @Override
- public String toString() {
- return "annotated with @" + annotation.getSimpleName();
- }
- }
-
- /**
- * A Test that checks to see if the class name matches.
- */
- public static class NameIs extends ResourceTest {
- private final String name;
-
- public NameIs(final String name) { this.name = '/' + name; }
-
- @Override
- public boolean matches(final URI resource) {
- return resource.getPath().endsWith(name);
- }
-
- @Override public String toString() {
- return "named " + name;
- }
- }
}