Author: nickarls
Date: 2008-11-28 05:38:13 -0500 (Fri, 28 Nov 2008)
New Revision: 379
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
Log:
toString simplifications, forwardingmap refactorings/renamings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-11-28
09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -44,7 +44,6 @@
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.bean.AbstractBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.bean.proxy.ProxyPool;
import org.jboss.webbeans.contexts.ApplicationContext;
@@ -58,7 +57,6 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
-import org.jboss.webbeans.transaction.TransactionListener;
import org.jboss.webbeans.util.Reflections;
/**
@@ -103,8 +101,6 @@
protected void initStandardBeans()
{
addBean(new
SimpleBean<DefaultEnterpriseBeanLookup>(DefaultEnterpriseBeanLookup.class, this));
-// TODO: Fix tests that rely that there are a specific number of beans
registered/present/matched etc.
-// addBean(new EnterpriseBean<TransactionListener>(TransactionListener.class,
this));
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2008-11-28
09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -27,6 +27,7 @@
import org.jboss.webbeans.model.BindingTypeModel;
import org.jboss.webbeans.model.ScopeModel;
import org.jboss.webbeans.model.StereotypeModel;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -65,32 +66,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Binding types: " + bindingTypes.size() +
"\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, BindingTypeModel<?>>
entry : bindingTypes.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ":
" + entry.getValue().toString() + "\n");
- }
- buffer.append("EJB metadata: " + ejbMetaDataMap.size() +
"\n");
- i = 0;
- for (Entry<Class<?>, EjbMetaData<?>> entry :
ejbMetaDataMap.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ":
" + entry.getValue().toString() + "\n");
- }
- buffer.append("Scopes: " + scopes.size() + "\n");
- i = 0;
- for (Entry<Class<? extends Annotation>, ScopeModel<?>> entry :
scopes.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ":
" + entry.getValue().toString() + "\n");
- }
- buffer.append("Stereotypes: " + stereotypes.size() + "\n");
- i = 0;
- for (Entry<Class<? extends Annotation>, StereotypeModel<?>>
entry : stereotypes.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ":
" + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotationModelMap (annotation -> ?):
", delegate);
}
}
@@ -114,11 +90,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Scope model map\n");
- buffer.append("--------------------\n");
- buffer.append(super.toString() + "\n");
- return buffer.toString();
+ return Strings.mapToString("ScopeModelMap (annotation -> ScopeModel):
", delegate);
}
}
@@ -142,11 +114,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Binding type model map\n");
- buffer.append("--------------------\n");
- buffer.append(super.toString() + "\n");
- return buffer.toString();
+ return Strings.mapToString("BindingTypeModelMap (annotation ->
BindingTypeModel): ", delegate);
}
}
@@ -181,15 +149,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("EJB metadata: " + delegate.size() + "\n");
- buffer.append("--------------------\n");
- int i = 0;
- for (Entry<Class<?>, EjbMetaData<?>> entry :
delegate.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ":
" + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("EJBMetadataMap (class -> EJBMetaData):
", delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-11-28
09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -39,6 +39,7 @@
import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
import org.jboss.webbeans.model.BindingTypeModel;
import org.jboss.webbeans.util.ListComparator;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -119,10 +120,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotated item\n");
- buffer.append(delegate().toString() + "\n");
- return buffer.toString();
+ return Strings.mapToString("AnnotatedItemMap (annotated item -> bean
set): ", delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -31,6 +31,7 @@
import javax.webbeans.manager.Bean;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -73,14 +74,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Proxy pool holding " + delegate.size() + "
proxies\n");
- int i = 0;
- for (Entry<Bean<?>, Object> entry : delegate.entrySet())
- {
- buffer.append(i + " - " + entry.getKey().toString() + ":
" + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("ProxyPool (bean -> proxy): ",
delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -24,6 +24,8 @@
import javax.webbeans.manager.Context;
+import org.jboss.webbeans.util.Strings;
+
import com.google.common.collect.ForwardingMap;
/**
@@ -79,16 +81,6 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Scope type -> context list mappings: " +
delegate.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, List<Context>> entry :
delegate.entrySet())
- {
- for (Context context : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ":
" + context.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("ContextMAp (scope type -> context list):
", delegate);
}
}
\ No newline at end of file
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -25,6 +25,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -131,14 +132,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Bean -> bean instance mappings: " + delegate.size() +
"\n");
- int i = 0;
- for (Entry<Bean<? extends Object>, Object> entry :
delegate.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": "
+ entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("SimpleBeanMap (bean -> instance): ",
delegate);
}
}
\ No newline at end of file
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -35,6 +35,7 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
import org.jboss.webbeans.util.Types;
import com.google.common.collect.ForwardingMap;
@@ -81,14 +82,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> annotation mappings: " +
super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Annotation> entry :
delegate.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotationMap (annotation type ->
annotation): ", delegate);
}
}
@@ -144,17 +138,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> meta annotation mappings: " +
super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<Annotation>> entry
: delegate.entrySet())
- {
- for (Annotation annotation : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + annotation.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("MetaAnnotationMap (annotation type ->
annotation set: ", delegate);
}
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -17,13 +17,21 @@
package org.jboss.webbeans.introspector.jlr;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.webbeans.BindingType;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
+import com.google.common.collect.ForwardingMap;
+
/**
* Represents an abstract annotated memeber (field, method or constructor)
*
@@ -34,6 +42,31 @@
*/
public abstract class AbstractAnnotatedMember<T, S extends Member> extends
AbstractAnnotatedItem<T, S>
{
+ /**
+ * An annotation type -> list of annotations map
+ */
+ protected class AnnotatedParameterMap extends ForwardingMap<Class<? extends
Annotation>, List<AnnotatedParameter<Object>>>
+ {
+ private Map<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> delegate;
+
+ public AnnotatedParameterMap()
+ {
+ delegate = new HashMap<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>>();
+ }
+
+ @Override
+ protected Map<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> delegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public String toString()
+ {
+ return Strings.mapToString("AnnotatedParameterMap (annotation type ->
parameter abstraction list): ", delegate);
+ }
+ }
+
// The name of the member
private String name;
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -27,6 +27,7 @@
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -43,11 +44,11 @@
/**
* A (annotation type -> set of method abstractions with annotation) map
*/
- private class AnnotatedMembers extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedMethod<?>>>
+ private class AnnotatedMemberMap extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedMethod<?>>>
{
private Map<Class<? extends Annotation>,
Set<AnnotatedMethod<?>>> delegate;
- public AnnotatedMembers()
+ public AnnotatedMemberMap()
{
delegate = new HashMap<Class<? extends Annotation>,
Set<AnnotatedMethod<?>>>();
}
@@ -61,22 +62,12 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> member abstraction mappings: " +
super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
Set<AnnotatedMethod<?>>> entry : delegate.entrySet())
- {
- for (AnnotatedMethod<?> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedMemberMap (annotation type -> set
of member abstractions: ", delegate);
}
}
// The annotated members map (annotation -> member with annotation)
- private AnnotatedMembers annotatedMembers;
+ private AnnotatedMemberMap annotatedMembers;
// The implementation class of the annotation
private Class<T> clazz;
// The set of abstracted members
@@ -170,7 +161,7 @@
* @param annotationType The annotation type to match
* @return The set of abstracted members with the given annotation type
* present. An empty set is returned if no matches are found
- *
+ *
* @see
org.jboss.webbeans.introspector.AnnotatedAnnotation#getAnnotatedMembers(Class)
*/
public Set<AnnotatedMethod<?>> getAnnotatedMembers(Class<? extends
Annotation> annotationType)
@@ -205,7 +196,7 @@
{
initMembers();
}
- annotatedMembers = new AnnotatedMembers();
+ annotatedMembers = new AnnotatedMemberMap();
for (AnnotatedMethod<?> member : members)
{
for (Annotation annotation : member.getAnnotations())
@@ -227,17 +218,18 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
-// buffer.append("AnnotatedConstructorImpl:\n");
-// buffer.append(super.toString() + "\n");
-// buffer.append("Class: " + clazz.toString() + "\n");
-//
-// buffer.append("Members: " + getMembers().size() + "\n");
-// int i = 0;
-// for (AnnotatedMethod<?> member : getMembers())
-// {
-// buffer.append(++i + " - " + member.toString());
-// }
-// buffer.append(annotatedMembers == null ? "" :
(annotatedMembers.toString() + "\n"));
+ // buffer.append("AnnotatedConstructorImpl:\n");
+ // buffer.append(super.toString() + "\n");
+ // buffer.append("Class: " + clazz.toString() + "\n");
+ //
+ // buffer.append("Members: " + getMembers().size() + "\n");
+ // int i = 0;
+ // for (AnnotatedMethod<?> member : getMembers())
+ // {
+ // buffer.append(++i + " - " + member.toString());
+ // }
+ // buffer.append(annotatedMembers == null ? "" :
+ // (annotatedMembers.toString() + "\n"));
return buffer.toString();
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -35,6 +35,7 @@
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -49,13 +50,13 @@
{
/**
- * A (annotation type -> set of field abstractions with annotation) map
+ * A (annotation type -> set of field abstractions with annotation/meta annotation)
map
*/
- private static class AnnotatedFields extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedField<Object>>>
+ private static class AnnotatedFieldMap extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedField<Object>>>
{
private Map<Class<? extends Annotation>,
Set<AnnotatedField<Object>>> delegate;
- public AnnotatedFields()
+ public AnnotatedFieldMap()
{
delegate = new HashMap<Class<? extends Annotation>,
Set<AnnotatedField<Object>>>();
}
@@ -69,64 +70,19 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> field abstraction mappings: " +
super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
Set<AnnotatedField<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedField<Object> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedFieldMap (annotation type -> field
abstraction set): ", delegate);
}
}
/**
- * A (annotation type -> set of field abstractions with meta-annotation) map
- */
- private static class MetaAnnotatedFields extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedField<Object>>>
- {
- private Map<Class<? extends Annotation>,
Set<AnnotatedField<Object>>> delegate;
-
- public MetaAnnotatedFields()
- {
- delegate = new HashMap<Class<? extends Annotation>,
Set<AnnotatedField<Object>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>,
Set<AnnotatedField<Object>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Meta-annotation type -> method abstraction mappings:
" + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
Set<AnnotatedField<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedField<Object> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
- }
- }
-
- /**
* A (annotation type -> set of method abstractions with annotation) map
*/
- private class AnnotatedMethods extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedMethod<Object>>>
+ private class AnnotatedMethodMap extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedMethod<Object>>>
{
private Map<Class<? extends Annotation>,
Set<AnnotatedMethod<Object>>> delegate;
- public AnnotatedMethods()
+ public AnnotatedMethodMap()
{
delegate = new HashMap<Class<? extends Annotation>,
Set<AnnotatedMethod<Object>>>();
}
@@ -140,28 +96,18 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> method abstraction mappings: " +
super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
Set<AnnotatedMethod<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedMethod<Object> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedMethodMap (annotation type ->
method abstraction set): ", delegate);
}
}
/**
* A (annotation type -> set of constructor abstractions with annotation) map
*/
- private class AnnotatedConstructors extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedConstructor<T>>>
+ private class AnnotatedConstructorMap extends ForwardingMap<Class<? extends
Annotation>, Set<AnnotatedConstructor<T>>>
{
private Map<Class<? extends Annotation>,
Set<AnnotatedConstructor<T>>> delegate;
- public AnnotatedConstructors()
+ public AnnotatedConstructorMap()
{
delegate = new HashMap<Class<? extends Annotation>,
Set<AnnotatedConstructor<T>>>();
}
@@ -175,17 +121,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> constructor abstraction mappings:
" + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
Set<AnnotatedConstructor<T>>> entry : delegate.entrySet())
- {
- for (AnnotatedConstructor<T> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedConstructorMap (annotation type ->
constructor abstraction set): ", delegate);
}
}
@@ -193,11 +129,11 @@
* A (class list -> set of constructor abstractions with matching parameters)
* map
*/
- private class ConstructorsByArgument extends
ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
+ private class ConstructorsByArgumentMap extends
ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
{
private Map<List<Class<?>>, AnnotatedConstructor<T>>
delegate;
- public ConstructorsByArgument()
+ public ConstructorsByArgumentMap()
{
delegate = new HashMap<List<Class<?>>,
AnnotatedConstructor<T>>();
}
@@ -230,21 +166,21 @@
// The set of abstracted fields
private Set<AnnotatedField<Object>> fields;
// The map from annotation type to abstracted field with annotation
- private AnnotatedFields annotatedFields;
+ private AnnotatedFieldMap annotatedFields;
// The map from annotation type to abstracted field with meta-annotation
- private MetaAnnotatedFields metaAnnotatedFields;
+ private AnnotatedFieldMap metaAnnotatedFields;
// The set of abstracted methods
private Set<AnnotatedMethod<Object>> methods;
// The map from annotation type to abstracted method with annotation
- private AnnotatedMethods annotatedMethods;
+ private AnnotatedMethodMap annotatedMethods;
// The set of abstracted constructors
private Set<AnnotatedConstructor<T>> constructors;
// The map from annotation type to abstracted constructor with annotation
- private AnnotatedConstructors annotatedConstructors;
+ private AnnotatedConstructorMap annotatedConstructors;
// The map from class list to abstracted constructor
- private ConstructorsByArgument constructorsByArgumentMap;
+ private ConstructorsByArgumentMap constructorsByArgumentMap;
/**
* Constructor
@@ -373,7 +309,7 @@
{
if (metaAnnotatedFields == null)
{
- metaAnnotatedFields = new MetaAnnotatedFields();
+ metaAnnotatedFields = new AnnotatedFieldMap();
}
if (annotatedFields == null)
{
@@ -392,7 +328,7 @@
* @param metaAnnotatedFields The meta-annotated fields
* @return The meta-annotated fields map
*/
- protected static <T extends Annotation> MetaAnnotatedFields
populateMetaAnnotatedFieldMap(Class<T> metaAnnotationType, AnnotatedFields
annotatedFields, MetaAnnotatedFields metaAnnotatedFields)
+ protected static <T extends Annotation> AnnotatedFieldMap
populateMetaAnnotatedFieldMap(Class<T> metaAnnotationType, AnnotatedFieldMap
annotatedFields, AnnotatedFieldMap metaAnnotatedFields)
{
if (!metaAnnotatedFields.containsKey(metaAnnotationType))
{
@@ -440,7 +376,7 @@
{
initFields();
}
- annotatedFields = new AnnotatedFields();
+ annotatedFields = new AnnotatedFieldMap();
for (AnnotatedField<Object> field : fields)
{
for (Annotation annotation : field.getAnnotations())
@@ -539,7 +475,7 @@
{
initMethods();
}
- annotatedMethods = new AnnotatedMethods();
+ annotatedMethods = new AnnotatedMethodMap();
for (AnnotatedMethod<Object> member : methods)
{
for (Annotation annotation : member.getAnnotations())
@@ -564,7 +500,7 @@
private void initConstructors()
{
this.constructors = new HashSet<AnnotatedConstructor<T>>();
- this.constructorsByArgumentMap = new ConstructorsByArgument();
+ this.constructorsByArgumentMap = new ConstructorsByArgumentMap();
for (Constructor<?> constructor : clazz.getDeclaredConstructors())
{
AnnotatedConstructor<T> annotatedConstructor = new
AnnotatedConstructorImpl<T>((Constructor<T>) constructor, this);
@@ -617,7 +553,7 @@
{
initConstructors();
}
- annotatedConstructors = new AnnotatedConstructors();
+ annotatedConstructors = new AnnotatedConstructorMap();
for (AnnotatedConstructor<T> constructor : constructors)
{
for (Annotation annotation : constructor.getAnnotations())
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -22,9 +22,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.webbeans.ExecutionException;
@@ -33,8 +31,6 @@
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotatedType;
-import com.google.common.collect.ForwardingMap;
-
/**
* Represents an annotated constructor
*
@@ -44,42 +40,6 @@
*/
public class AnnotatedConstructorImpl<T> extends AbstractAnnotatedMember<T,
Constructor<T>> implements AnnotatedConstructor<T>
{
-
- /**
- * An annotation type -> list of annotations map
- */
- private class AnnotatedParameters extends ForwardingMap<Class<? extends
Annotation>, List<AnnotatedParameter<Object>>>
- {
- private Map<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> delegate;
-
- public AnnotatedParameters()
- {
- delegate = new HashMap<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> parameter abstraction mappings: "
+ super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedParameter<?> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
- }
- }
-
// The type arguments
private static final Type[] actualTypeArguments = new Type[0];
// The underlying constructor
@@ -88,7 +48,7 @@
// The list of parameter abstractions
private List<AnnotatedParameter<Object>> parameters;
// The mapping of annotation -> parameter abstraction
- private AnnotatedParameters annotatedParameters;
+ private AnnotatedParameterMap annotatedParameters;
// The declaring class abstraction
private AnnotatedType<T> declaringClass;
@@ -234,7 +194,7 @@
{
initParameters();
}
- annotatedParameters = new AnnotatedParameters();
+ annotatedParameters = new AnnotatedParameterMap();
for (AnnotatedParameter<Object> parameter : parameters)
{
for (Annotation annotation : parameter.getAnnotations())
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28
09:44:49 UTC (rev 378)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -22,9 +22,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -32,8 +30,6 @@
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Reflections;
-import com.google.common.collect.ForwardingMap;
-
/**
* Represents an annotated method
*
@@ -43,42 +39,6 @@
*/
public class AnnotatedMethodImpl<T> extends AbstractAnnotatedMember<T,
Method> implements AnnotatedMethod<T>
{
- /**
- * A annotation type -> list of parameter abstractions with given annotations
- * present mapping
- */
- private class AnnotatedParameters extends ForwardingMap<Class<? extends
Annotation>, List<AnnotatedParameter<Object>>>
- {
- private Map<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> delegate;
-
- public AnnotatedParameters()
- {
- delegate = new HashMap<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> parameter abstraction mappings: "
+ super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>,
List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedParameter<?> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ":
" + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
- }
- }
-
// The actual type arguments
private Type[] actualTypeArguments = new Type[0];
// The underlying method
@@ -88,7 +48,7 @@
private List<AnnotatedParameter<Object>> parameters;
// A mapping from annotation type to parameter abstraction with that
// annotation present
- private AnnotatedParameters annotatedParameters;
+ private AnnotatedParameterMap annotatedParameters;
// The property name
private String propertyName;
@@ -236,7 +196,7 @@
{
initParameters();
}
- annotatedParameters = new AnnotatedParameters();
+ annotatedParameters = new AnnotatedParameterMap();
for (AnnotatedParameter<Object> parameter : parameters)
{
for (Annotation annotation : parameter.getAnnotations())
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-28
09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-28
10:38:13 UTC (rev 379)
@@ -1,8 +1,15 @@
package org.jboss.webbeans.util;
import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.Map.Entry;
+import org.jboss.webbeans.introspector.AnnotatedField;
+
public class Strings
{
@@ -10,23 +17,47 @@
{
return Introspector.decapitalize(camelCase);
}
-
+
public static String[] split(String strings, String delims)
{
- if (strings==null)
+ if (strings == null)
{
return new String[0];
}
else
- {
+ {
StringTokenizer tokens = new StringTokenizer(strings, delims);
- String[] result = new String[ tokens.countTokens() ];
- int i=0;
- while ( tokens.hasMoreTokens() )
+ String[] result = new String[tokens.countTokens()];
+ int i = 0;
+ while (tokens.hasMoreTokens())
{
result[i++] = tokens.nextToken();
}
return result;
}
- }
+ }
+
+ public static String mapToString(String header, Map<?, ?> map)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(header + map.size() + "\n");
+ int i = 0;
+ for (Object key : map.keySet())
+ {
+ Object value = map.get(key);
+ if (value instanceof Iterable)
+ {
+ for (Object subValue : (Iterable<?>) value)
+ {
+ buffer.append(++i + " - " + key.toString() + ": " +
subValue.toString() + "\n");
+ }
+ }
+ else
+ {
+ buffer.append(++i + " - " + key.toString() + ": " +
value.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
+
}