[weld-commits] Weld SVN: r6068 - extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Tue Mar 30 05:55:01 EDT 2010
Author: swd847
Date: 2010-03-30 05:55:00 -0400 (Tue, 30 Mar 2010)
New Revision: 6068
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedTypeBuilder.java
Log:
added ability to override field type
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -23,7 +23,7 @@
protected AbstractNewAnnotatedCallable(AnnotatedType<X> declaringType, Y member, Class<?> memberType, Class<?>[] parameterTypes, AnnotationStore annotations, Map<Integer, AnnotationStore> parameterAnnotations, Type genericType)
{
- super(declaringType, member, memberType, annotations, genericType);
+ super(declaringType, member, memberType, annotations, genericType, null);
this.parameters = getAnnotatedParameters(this, parameterTypes, parameterAnnotations);
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -20,18 +20,29 @@
private final Set<Type> typeClosure;
private final AnnotationStore annotations;
- protected AbstractNewAnnotatedElement(Class<?> type, AnnotationStore annotations, Type genericType)
+ protected AbstractNewAnnotatedElement(Class<?> type, AnnotationStore annotations, Type genericType, Type overridenType)
{
- this.typeClosure = new TypeClosureBuilder().add(type).getTypes();
- if (genericType != null)
+
+ if (overridenType == null)
{
- typeClosure.add(genericType);
- this.type = genericType;
+ this.typeClosure = new TypeClosureBuilder().add(type).getTypes();
+ if (genericType != null)
+ {
+ typeClosure.add(genericType);
+ this.type = genericType;
+ }
+ else
+ {
+ this.type = type;
+ }
}
else
{
- this.type = type;
+ this.type = overridenType;
+ this.typeClosure = Collections.singleton(overridenType);
}
+
+
if (annotations == null)
{
this.annotations = new AnnotationStore();
@@ -66,5 +77,5 @@
{
return type;
}
-
+
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -17,9 +17,9 @@
private final AnnotatedType<X> declaringType;
private final M javaMember;
- protected AbstractNewAnnotatedMember(AnnotatedType<X> declaringType, M member, Class<?> memberType, AnnotationStore annotations, Type genericType)
+ protected AbstractNewAnnotatedMember(AnnotatedType<X> declaringType, M member, Class<?> memberType, AnnotationStore annotations, Type genericType, Type overridenType)
{
- super(memberType, annotations, genericType);
+ super(memberType, annotations, genericType, overridenType);
this.declaringType = declaringType;
this.javaMember = member;
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -1,6 +1,7 @@
package org.jboss.weld.extensions.util.annotated;
import java.lang.reflect.Field;
+import java.lang.reflect.Type;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -13,9 +14,9 @@
class NewAnnotatedField<X> extends AbstractNewAnnotatedMember<X, Field> implements AnnotatedField<X>
{
- NewAnnotatedField(AnnotatedType<X> declaringType, Field field, AnnotationStore annotations)
+ NewAnnotatedField(AnnotatedType<X> declaringType, Field field, AnnotationStore annotations, Type overridenType)
{
- super(declaringType, field, field.getType(), annotations, field.getGenericType());
+ super(declaringType, field, field.getType(), annotations, field.getGenericType(), overridenType);
}
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -16,7 +16,7 @@
NewAnnotatedParameter(AnnotatedCallable<X> declaringCallable, Class<?> type, int position, AnnotationStore annotations)
{
- super(type, annotations, null);
+ super(type, annotations, null, null);
this.declaringCallable = declaringCallable;
this.position = position;
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -3,6 +3,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@@ -37,9 +38,9 @@
* If annotation have been added to other methods as well we add them to
*
*/
- NewAnnotatedType(Class<X> clazz, AnnotationStore typeAnnotations, Map<Field, AnnotationStore> fieldAnnotations, Map<Method, AnnotationStore> methodAnnotations, Map<Method, Map<Integer, AnnotationStore>> methodParameterAnnotations, Map<Constructor<X>, AnnotationStore> constructorAnnotations, Map<Constructor<X>, Map<Integer, AnnotationStore>> constructorParameterAnnotations)
+ NewAnnotatedType(Class<X> clazz, AnnotationStore typeAnnotations, Map<Field, AnnotationStore> fieldAnnotations, Map<Method, AnnotationStore> methodAnnotations, Map<Method, Map<Integer, AnnotationStore>> methodParameterAnnotations, Map<Constructor<X>, AnnotationStore> constructorAnnotations, Map<Constructor<X>, Map<Integer, AnnotationStore>> constructorParameterAnnotations, Map<Field, Type> fieldTypes)
{
- super(clazz, typeAnnotations, null);
+ super(clazz, typeAnnotations, null, null);
this.javaClass = clazz;
this.constructors = new HashSet<AnnotatedConstructor<X>>();
Set<Constructor<?>> cset = new HashSet<Constructor<?>>();
@@ -77,7 +78,7 @@
this.fields = new HashSet<AnnotatedField<? super X>>();
for (Field f : clazz.getFields())
{
- NewAnnotatedField<X> b = new NewAnnotatedField<X>(this, f, fieldAnnotations.get(f));
+ NewAnnotatedField<X> b = new NewAnnotatedField<X>(this, f, fieldAnnotations.get(f), fieldTypes.get(f));
fields.add(b);
fset.add(f);
}
@@ -85,7 +86,7 @@
{
if (!fset.contains(e.getKey()))
{
- fields.add(new NewAnnotatedField<X>(this, e.getKey(), e.getValue()));
+ fields.add(new NewAnnotatedField<X>(this, e.getKey(), e.getValue(), fieldTypes.get(e.getKey())));
}
}
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedTypeBuilder.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedTypeBuilder.java 2010-03-28 21:03:47 UTC (rev 6067)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedTypeBuilder.java 2010-03-30 09:55:00 UTC (rev 6068)
@@ -4,6 +4,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -38,6 +39,8 @@
private AnnotationBuilder typeAnnotations = new AnnotationBuilder();
private Class<X> underlying;
+ private Map<Field, Type> fieldTypes = new HashMap<Field, Type>();
+
public NewAnnotatedTypeBuilder(Class<X> underlying)
{
this(underlying, false);
@@ -537,7 +540,12 @@
}
}
- return new NewAnnotatedType<X>(underlying, typeAnnotations.create(), fieldAnnotations, methodAnnotations, methodParameterAnnnotations, constructorAnnotations, constructorParameterAnnnotations);
+ return new NewAnnotatedType<X>(underlying, typeAnnotations.create(), fieldAnnotations, methodAnnotations, methodParameterAnnnotations, constructorAnnotations, constructorParameterAnnnotations, fieldTypes);
}
+ public void overrideFieldType(Field field, Type type)
+ {
+ fieldTypes.put(field, type);
+ }
+
}
More information about the weld-commits
mailing list