You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/13 19:10:16 UTC
svn commit: r1135178 [2/3] - in /commons/sandbox/meiyo/trunk: ./ src/
src/changes/ src/main/ src/main/assembly/ src/main/java/ src/main/java/org/
src/main/java/org/nnsoft/ src/main/java/org/nnsoft/commons/
src/main/java/org/nnsoft/commons/meiyo/ src/ma...
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,70 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.util.regex.Pattern;
+
+/**
+ * A filter that verifies the class found name matches against a given pattern.
+ */
+final class ClassNameMatchesFilter
+ extends AbstractFilter
+{
+
+ /**
+ * The class name pattern has to be matched.
+ */
+ private final Pattern pattern;
+
+ /**
+ * Creates a new class name matcher.
+ *
+ * @param regex the class name regexp pattern has to be matched.
+ */
+ public ClassNameMatchesFilter( String regex )
+ {
+ this( Pattern.compile( regex ) );
+ }
+
+ /**
+ * Creates a new class name matcher.
+ *
+ * @param pattern the class name pattern has to be matched.
+ */
+ public ClassNameMatchesFilter( Pattern pattern )
+ {
+ this.pattern = pattern;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return this.pattern.matcher( clazz.getSimpleName() ).matches();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "classNameMatches(%s)", this.pattern.toString() );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ClassNameMatchesFilter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,103 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+
+/**
+ * A filter that verifies the class found contains a method with the given signature.
+ */
+final class ContainsMethod
+ extends AbstractFilter
+{
+
+ /**
+ * The method name has to be contained in the class found.
+ */
+ private final String name;
+
+ /**
+ * The method arguments type.
+ */
+ private final Class<?>[] argumentsType;
+
+ /**
+ * Creates a new {@code ContainsMethod} instance.
+ *
+ * @param name the method name has to be contained in the class found.
+ * @param argumentsType the optional method arguments type.
+ */
+ public ContainsMethod( String name, Class<?>... argumentsType )
+ {
+ this.name = name;
+ this.argumentsType = argumentsType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ Class<?> current = clazz;
+ while ( current != null )
+ {
+ for ( Method method : getDeclaredMethods( current ) )
+ {
+ if ( this.name.equals( method.getName() )
+ && Arrays.equals( this.argumentsType, method.getParameterTypes() ) )
+ {
+ return true;
+ }
+ }
+ current = current.getSuperclass();
+ }
+ return false;
+ }
+
+ /**
+ * Returns all the declared methods in the given class, using the privileged access.
+ *
+ * @param type the class from which extract the declared methods.
+ * @return the declared methods array.
+ */
+ private static Method[] getDeclaredMethods( final Class<?> type )
+ {
+ return AccessController.doPrivileged( new PrivilegedAction<Method[]>()
+ {
+ public Method[] run()
+ {
+ final Method[] declaredMethods = type.getDeclaredMethods();
+ AccessibleObject.setAccessible( declaredMethods, true );
+ return declaredMethods;
+ }
+ } );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "containsMethod(%s(%s))", this.name, Arrays.toString( this.argumentsType ) );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/ContainsMethod.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,44 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * A filter is a class, found in the classpath, discriminator.
+ */
+public interface Filter
+{
+
+ /**
+ * Returns {@code true} if the given class satisfies the requirements, {@code false} otherwise.
+ *
+ * @return {@code true} if the given class satisfies the requirements, {@code false} otherwise.
+ */
+ boolean matches( Class<?> clazz );
+
+ Filter and( Filter other );
+
+ Filter nand( Filter other );
+
+ Filter or( Filter other );
+
+ Filter nor( Filter other );
+
+ Filter xor( Filter other );
+
+ Filter xnor( Filter other );
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,180 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Simple filters language implementation.
+ */
+public final class Filters
+{
+
+ /**
+ * This class can't be instantiated.
+ */
+ private Filters()
+ {
+ // do nothing
+ }
+
+ public static Filter annotatedWith( Annotation annotation )
+ {
+ if ( annotation == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'annotation' must not be null" );
+ }
+
+ checkForRuntimeRetention( annotation.annotationType() );
+
+ return new AnnotatedWith( annotation );
+ }
+
+ public static Filter annotatedWithType( Class<? extends Annotation> annotationType )
+ {
+ if ( annotationType == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'annotationType' must not be null" );
+ }
+
+ checkForRuntimeRetention( annotationType );
+
+ return new AnnotatedWithType( annotationType );
+ }
+
+ private static void checkForRuntimeRetention( Class<? extends Annotation> annotationType )
+ {
+ Retention retention = annotationType.getAnnotation( Retention.class );
+ if ( retention == null || RetentionPolicy.RUNTIME != retention.value() )
+ {
+ throw new IllegalArgumentException( "Annotation @" + annotationType.getName()
+ + " is missing RUNTIME retention" );
+ }
+ }
+
+ public static Filter any()
+ {
+ return new Any();
+ }
+
+ public static Filter classNameMatches( String regex )
+ {
+ if ( regex == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'regex' must not be null" );
+ }
+ if ( regex.length() == 0 )
+ {
+ throw new IllegalArgumentException( "Empty 'regex' not allowed" );
+ }
+
+ return new ClassNameMatchesFilter( regex );
+ }
+
+ public static Filter containsMethod( String name, Class<?>... argumentsType )
+ {
+ if ( name == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'name' must not be null" );
+ }
+
+ return new ContainsMethod( name, argumentsType );
+ }
+
+ public static Filter inPackage( String targetPackage )
+ {
+ if ( targetPackage == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'targetPackage' must be not null" );
+ }
+
+ return new InPackage( targetPackage );
+ }
+
+ public static Filter inSubpackage( String targetPackage )
+ {
+ if ( targetPackage == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'targetPackage' must be not null" );
+ }
+
+ return new InSubpackage( targetPackage );
+ }
+
+ public static Filter isAbstract()
+ {
+ return new IsAbstract();
+ }
+
+ public static Filter isAnnotation()
+ {
+ return new IsAnnotation();
+ }
+
+ public static Filter isAssignableTo( Class<?> superclassOrInterface )
+ {
+ if ( superclassOrInterface == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'superclassOrInterface' must be not null" );
+ }
+
+ return new IsAssignableTo( superclassOrInterface );
+ }
+
+ public static Filter isFinal()
+ {
+ return new IsFinal();
+ }
+
+ public static Filter isInterface()
+ {
+ return new IsInterface();
+ }
+
+ public static Filter isPrivate()
+ {
+ return new IsPrivate();
+ }
+
+ public static Filter isPublic()
+ {
+ return new IsPublic();
+ }
+
+ public static Filter isStatic()
+ {
+ return new IsStatic();
+ }
+
+ public static Filter isStrict()
+ {
+ return new IsStrict();
+ }
+
+ public static Filter not( Filter delegate )
+ {
+ if ( delegate == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'delegate' must be not null" );
+ }
+
+ return new Not( delegate );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Filters.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,58 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Filter that verifies the found class is exactly in the given package.
+ */
+final class InPackage
+ extends AbstractFilter
+{
+
+ /**
+ * The package where classes are looked for.
+ */
+ private final String targetPackage;
+
+ /**
+ * Creates a new package based filter.
+ *
+ * @param targetPackage the package where classes are looked for.
+ */
+ public InPackage( String targetPackage )
+ {
+ this.targetPackage = targetPackage;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return this.targetPackage.equals( clazz.getPackage().getName() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "inPackage(%s)", this.targetPackage );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InPackage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,60 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Filter that verifies the found class is in the given package or subpackage.
+ */
+final class InSubpackage
+ extends AbstractFilter
+{
+
+ /**
+ * The root package where classes are looked for.
+ */
+ private final String targetPackageName;
+
+ /**
+ * Creates a new (sub)package based filter.
+ *
+ * @param targetPackageName the package where classes are looked for.
+ */
+ public InSubpackage( String targetPackageName )
+ {
+ this.targetPackageName = targetPackageName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ String classPackageName = clazz.getPackage().getName();
+ return classPackageName.equals( this.targetPackageName )
+ || classPackageName.startsWith( this.targetPackageName + '.' );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "inSubPackage(%s)", this.targetPackageName );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/InSubpackage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsAbstract
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isAbstract( clazz.getModifiers() ) && !clazz.isInterface();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isAbstract()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAbstract.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,43 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @version $Id$
+ */
+final class IsAnnotation
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return clazz.isAnnotation();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isAnnotation()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAnnotation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,50 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @version $Id$
+ */
+final class IsAssignableTo
+ extends AbstractFilter
+{
+
+ private final Class<?> superclassOrInterface;
+
+ public IsAssignableTo( Class<?> superclassOrInterface )
+ {
+ this.superclassOrInterface = superclassOrInterface;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return this.superclassOrInterface.isAssignableFrom( clazz );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "isAssignableTo(%s)", this.superclassOrInterface.getSimpleName() );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsAssignableTo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsFinal
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isFinal( clazz.getModifiers() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isFinal()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsFinal.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsInterface
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isInterface( clazz.getModifiers() ) && !clazz.isAnnotation();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isInterface()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsInterface.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsPrivate
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isPrivate( clazz.getModifiers() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isPrivate()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPrivate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsPublic
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isPublic( clazz.getModifiers() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isPublic()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsPublic.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsStatic
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isStatic( clazz.getModifiers() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isStatic()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStatic.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,45 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ */
+final class IsStrict
+ extends AbstractFilter
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return Modifier.isStrict( clazz.getModifiers() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return "isStrict()";
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/IsStrict.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,54 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @version $Id$
+ */
+final class Not
+ extends AbstractFilter
+{
+
+ final Filter delegate;
+
+ public Not( Filter delegate )
+ {
+ if ( delegate == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'delegate' must not be null" );
+ }
+ this.delegate = delegate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return !this.delegate.matches( clazz );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "not(%s)", this.delegate );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Not.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,50 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @version $Id$
+ */
+class Or
+ extends AbstractFilter
+{
+
+ private final Filter a;
+
+ private final Filter b;
+
+ public Or( Filter a, Filter b )
+ {
+ this.a = a;
+ this.b = b;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return this.a.matches( clazz ) || this.b.matches( clazz );
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format( "or(%s, %s)", this.a, this.b );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Or.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,50 @@
+package org.nnsoft.commons.meiyo.classpath.filter;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @version $Id$
+ */
+final class Xor
+ extends AbstractFilter
+{
+
+ private final Filter a;
+
+ private final Filter b;
+
+ public Xor( Filter a, Filter b )
+ {
+ this.a = a;
+ this.b = b;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches( Class<?> clazz )
+ {
+ return this.a.matches( clazz ) ^ this.b.matches( clazz );
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format( "xor(%s, %s)", this.a, this.b );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/Xor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,21 @@
+/**
+ * Contains the backport SPI APIs implementation.
+ *
+ * @version $Id$
+ */
+package org.nnsoft.commons.meiyo.classpath.filter;
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/filter/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,22 @@
+/**
+ * Contains the base classpath scanner interfaces.
+ *
+ * @version $Id$
+ */
+package org.nnsoft.commons.meiyo.classpath;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classpath/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,85 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public abstract class AbstractVisitorConfiguration
+ implements VisitorConfiguration
+{
+
+ private AnnotationHandlerBinder wrapped;
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void configure( final AnnotationHandlerBinder binder )
+ {
+ if ( wrapped != null )
+ {
+ throw new IllegalStateException( "Re-entry is not allowed." );
+ }
+
+ wrapped = binder;
+
+ try
+ {
+ configure();
+ }
+ finally
+ {
+ wrapped = null;
+ }
+ }
+
+ protected abstract void configure();
+
+ /**
+ * {@inheritDoc}
+ */
+ protected AnnotatedHandlerBuilder<Class> handleType()
+ {
+ return wrapped.handleType();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected AnnotatedHandlerBuilder<Constructor> handleConstructor()
+ {
+ return wrapped.handleConstructor();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected AnnotatedHandlerBuilder<Field> handleField()
+ {
+ return wrapped.handleField();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected AnnotatedHandlerBuilder<Method> handleMethod()
+ {
+ return wrapped.handleMethod();
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AbstractVisitorConfiguration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,30 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * FILL ME.
+ */
+public interface AnnotatedHandlerBuilder<E extends AnnotatedElement>
+{
+
+ <A extends Annotation> LinkedHandlingBuilder<E, A> annotatedWith( Class<A> annotationType );
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotatedHandlerBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,32 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * FILL ME.
+ *
+ * @version $Id$
+ */
+public interface AnnotationHandler<E extends AnnotatedElement, A extends Annotation>
+{
+
+ void handle( E annnotatedElement, A annotation );
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,37 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * FILL ME.
+ */
+public interface AnnotationHandlerBinder
+{
+
+ AnnotatedHandlerBuilder<Class> handleType();
+
+ AnnotatedHandlerBuilder<Constructor> handleConstructor();
+
+ AnnotatedHandlerBuilder<Field> handleField();
+
+ AnnotatedHandlerBuilder<Method> handleMethod();
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,89 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+final class AnnotationHandlerBinderImpl
+ implements AnnotationHandlerBinder
+{
+
+ private final Map<Key, AnnotationHandler<AnnotatedElement, Annotation>> registry =
+ new HashMap<Key, AnnotationHandler<AnnotatedElement, Annotation>>();
+
+ public AnnotatedHandlerBuilder<Class> handleType()
+ {
+ return this.handleElement( Class.class );
+ }
+
+ public AnnotatedHandlerBuilder<Constructor> handleConstructor()
+ {
+ return this.handleElement( Constructor.class );
+ }
+
+ public AnnotatedHandlerBuilder<Field> handleField()
+ {
+ return this.handleElement( Field.class );
+ }
+
+ public AnnotatedHandlerBuilder<Method> handleMethod()
+ {
+ return this.handleElement( Method.class );
+ }
+
+ private <E extends AnnotatedElement> AnnotatedHandlerBuilder<E> handleElement( final Class<E> annotatedElementType )
+ {
+ return new AnnotatedHandlerBuilder<E>()
+ {
+ public <A extends Annotation> LinkedHandlingBuilder<E, A> annotatedWith( final Class<A> annotationType )
+ {
+ if ( annotationType == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'annotationType' must not be null" );
+ }
+
+ return new LinkedHandlingBuilder<E, A>()
+ {
+ @SuppressWarnings( "unchecked" )
+ public void withHandler( AnnotationHandler<E, A> handler )
+ {
+ if ( handler == null )
+ {
+ throw new IllegalArgumentException( "Parameter 'handler' must not be null" );
+ }
+
+ AnnotationHandlerBinderImpl.this.registry.put( new Key( annotatedElementType, annotationType ),
+ (AnnotationHandler<AnnotatedElement, Annotation>) handler );
+ }
+ };
+ }
+ };
+ }
+
+ public AnnotationHandler<AnnotatedElement, Annotation> getHandler( Class<? extends AnnotatedElement> annotatedElementType,
+ Class<? extends Annotation> annotationType )
+ {
+ return this.registry.get( new Key( annotatedElementType, annotationType ) );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/AnnotationHandlerBinderImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,27 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * FILL ME.
+ */
+public interface ClassVisitor
+{
+
+ void visit( final Class<?> type );
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,117 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * FILL ME.
+ */
+final class ClassVisitorImpl
+ implements ClassVisitor
+{
+
+ private static final String JAVA_PACKAGE = "java";
+
+ private final AnnotationHandlerBinderImpl binder;
+
+ public ClassVisitorImpl( final AnnotationHandlerBinderImpl binder )
+ {
+ this.binder = binder;
+ }
+
+ public void visit( final Class<?> type )
+ {
+ if ( type == null || type.getPackage().getName().startsWith( JAVA_PACKAGE ) )
+ {
+ return;
+ }
+
+ // TYPE
+ this.visitElements( type );
+
+ if ( !type.isInterface() )
+ {
+ // CONSTRUCTOR
+ this.visitElements( new PrivilegedAction<Constructor<?>[]>()
+ {
+ public Constructor<?>[] run()
+ {
+ return type.getDeclaredConstructors();
+ }
+ } );
+
+ // FIELD
+ this.visitElements( new PrivilegedAction<Field[]>()
+ {
+ public Field[] run()
+ {
+ return type.getDeclaredFields();
+ }
+ } );
+ }
+
+ // METHOD
+ this.visitElements( new PrivilegedAction<Method[]>()
+ {
+ public Method[] run()
+ {
+ return type.getDeclaredMethods();
+ }
+ } );
+
+ this.visit( type.getSuperclass() );
+ }
+
+ private <AE extends AnnotatedElement> void visitElements( PrivilegedAction<AE[]> action )
+ {
+ AE[] annotatedElements = null;
+ if ( System.getSecurityManager() != null )
+ {
+ annotatedElements = AccessController.doPrivileged( action );
+ }
+ else
+ {
+ annotatedElements = action.run();
+ }
+ this.visitElements( annotatedElements );
+ }
+
+ private void visitElements( AnnotatedElement... annotatedElements )
+ {
+ for ( AnnotatedElement element : annotatedElements )
+ {
+ for ( Annotation annotation : element.getAnnotations() )
+ {
+ AnnotationHandler<AnnotatedElement, Annotation> handler =
+ this.binder.getHandler( element.getClass(), annotation.annotationType() );
+
+ if ( handler != null )
+ {
+ handler.handle( element, annotation );
+ }
+ }
+ }
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/ClassVisitorImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,119 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * FILL ME.
+ */
+final class Key
+{
+
+ private final Class<? extends AnnotatedElement> annotatedElementType;
+
+ private final Class<? extends Annotation> annotationType;
+
+ public Key( Class<? extends AnnotatedElement> annotatedElementType, Class<? extends Annotation> annotationType )
+ {
+ this.annotatedElementType = annotatedElementType;
+ this.annotationType = annotationType;
+ }
+
+ protected Class<? extends AnnotatedElement> getAnnotatedElementType()
+ {
+ return this.annotatedElementType;
+ }
+
+ protected Class<? extends Annotation> getAnnotationType()
+ {
+ return this.annotationType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( this.annotatedElementType == null ) ? 0 : this.annotatedElementType.hashCode() );
+ result = prime * result + ( ( this.annotationType == null ) ? 0 : this.annotationType.hashCode() );
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( obj == null )
+ {
+ return false;
+ }
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
+ Key other = (Key) obj;
+
+ if ( this.annotatedElementType == null )
+ {
+ if ( other.getAnnotatedElementType() != null )
+ {
+ return false;
+ }
+ }
+ else if ( !this.annotatedElementType.equals( other.getAnnotatedElementType() ) )
+ {
+ return false;
+ }
+
+ if ( this.annotationType == null )
+ {
+ if ( other.getAnnotationType() != null )
+ {
+ return false;
+ }
+ }
+ else if ( !this.annotationType.equals( other.getAnnotationType() ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "Key [annotatedElementType=%s, annotationType=%s]", this.annotatedElementType,
+ this.annotationType );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/Key.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,30 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * FILL ME.
+ */
+public interface LinkedHandlingBuilder<E extends AnnotatedElement, A extends Annotation>
+{
+
+ void withHandler( AnnotationHandler<E, A> handler );
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/LinkedHandlingBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,55 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+import java.util.Arrays;
+import java.util.Collection;
+
+public final class MeiyoVisitor
+{
+
+ private MeiyoVisitor()
+ {
+ // do nothing
+ }
+
+ public static ClassVisitor createVisitor( VisitorConfiguration... configurations )
+ {
+ if ( configurations == null || configurations.length == 0 )
+ {
+ throw new IllegalArgumentException( "At least one VisitorConfiguration has to be specified" );
+ }
+ return createVisitor( Arrays.asList( configurations ) );
+ }
+
+ public static ClassVisitor createVisitor( Collection<VisitorConfiguration> configurations )
+ {
+ if ( configurations == null || configurations.isEmpty() )
+ {
+ throw new IllegalArgumentException( "Parameter 'configurations' must not be null or empty" );
+ }
+
+ AnnotationHandlerBinderImpl binderImpl = new AnnotationHandlerBinderImpl();
+ for ( VisitorConfiguration module : configurations )
+ {
+ module.configure( binderImpl );
+ }
+
+ return new ClassVisitorImpl( binderImpl );
+ }
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/MeiyoVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java
URL: http://svn.apache.org/viewvc/commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java?rev=1135178&view=auto
==============================================================================
--- commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java (added)
+++ commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java Mon Jun 13 17:10:13 2011
@@ -0,0 +1,27 @@
+package org.nnsoft.commons.meiyo.classvisitor;
+
+/*
+ * Copyright 2010-2011 The 99 Software Foundation
+ *
+ * Licensed 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.
+ */
+
+/**
+ * FILL ME.
+ */
+public interface VisitorConfiguration
+{
+
+ void configure( AnnotationHandlerBinder binder );
+
+}
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/meiyo/trunk/src/main/java/org/nnsoft/commons/meiyo/classvisitor/VisitorConfiguration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain