use of org.glassfish.hk2.xml.internal.alt.AltAnnotation in project glassfish-hk2 by eclipse-ee4j.
the class Generator method createAnnotationCopy.
private static void createAnnotationCopy(ConstPool parent, AltAnnotation javaAnnotation, AnnotationsAttribute retVal) throws Throwable {
Annotation addMe = createAnnotationCopyOnly(parent, javaAnnotation);
retVal.addAnnotation(addMe);
}
use of org.glassfish.hk2.xml.internal.alt.AltAnnotation in project glassfish-hk2 by eclipse-ee4j.
the class Utilities method getAdapterInformation.
private static AdapterInformation getAdapterInformation(AltMethod method) {
AltAnnotation adapterAnnotation = isSpecifiedAdapted(method);
if (adapterAnnotation == null)
return null;
AltClass adapter = adapterAnnotation.getClassValue("value");
AltClass valueType = adapter.getSuperParameterizedType(ClassAltClassImpl.XML_ADAPTER, 0);
AltClass boundType = adapter.getSuperParameterizedType(ClassAltClassImpl.XML_ADAPTER, 1);
return new AdapterInformationImpl(adapter, valueType, boundType);
}
use of org.glassfish.hk2.xml.internal.alt.AltAnnotation in project glassfish-hk2 by eclipse-ee4j.
the class MethodAltMethodImpl method getAnnotations.
/* (non-Javadoc)
* @see org.glassfish.hk2.xml.internal.alt.AltMethod#getAnnotations()
*/
@Override
public synchronized List<AltAnnotation> getAnnotations() {
if (altAnnotations != null)
return altAnnotations;
Annotation[] annotations = method.getAnnotations();
ArrayList<AltAnnotation> retVal = new ArrayList<AltAnnotation>(annotations.length);
for (Annotation annotation : annotations) {
retVal.add(new AnnotationAltAnnotationImpl(annotation, helper));
}
altAnnotations = Collections.unmodifiableList(retVal);
return altAnnotations;
}
use of org.glassfish.hk2.xml.internal.alt.AltAnnotation in project glassfish-hk2 by eclipse-ee4j.
the class AnnotationAltAnnotationImpl method getAnnotationValues.
/* (non-Javadoc)
* @see org.glassfish.hk2.xml.internal.alt.AltAnnotation#getAnnotationValues()
*/
@Override
public synchronized Map<String, Object> getAnnotationValues() {
if (values != null)
return values;
Map<String, Object> retVal = new TreeMap<String, Object>();
for (Method javaAnnotationMethod : annotation.annotationType().getMethods()) {
if (javaAnnotationMethod.getParameterTypes().length != 0)
continue;
if (DO_NOT_HANDLE_METHODS.contains(javaAnnotationMethod.getName()))
continue;
String key = javaAnnotationMethod.getName();
Object value;
try {
value = ReflectionHelper.invoke(annotation, javaAnnotationMethod, new Object[0], false);
if (value == null) {
throw new AssertionError("Recieved null from annotation method " + javaAnnotationMethod.getName());
}
} catch (RuntimeException re) {
throw re;
} catch (Throwable th) {
throw new RuntimeException(th);
}
if (value instanceof Class) {
value = new ClassAltClassImpl((Class<?>) value, helper);
} else if (Enum.class.isAssignableFrom(value.getClass())) {
value = new EnumAltEnumImpl((Enum<?>) value);
} else if (value.getClass().isArray() && Class.class.equals(value.getClass().getComponentType())) {
Class<?>[] cValue = (Class<?>[]) value;
AltClass[] translatedValue = new AltClass[cValue.length];
for (int lcv = 0; lcv < cValue.length; lcv++) {
translatedValue[lcv] = new ClassAltClassImpl(cValue[lcv], helper);
}
value = translatedValue;
} else if (value.getClass().isArray() && Enum.class.isAssignableFrom(value.getClass().getComponentType())) {
Enum<?>[] eValue = (Enum<?>[]) value;
AltEnum[] translatedValue = new AltEnum[eValue.length];
for (int lcv = 0; lcv < eValue.length; lcv++) {
translatedValue[lcv] = new EnumAltEnumImpl(eValue[lcv]);
}
value = translatedValue;
} else if (value.getClass().isArray() && Annotation.class.isAssignableFrom(value.getClass().getComponentType())) {
Annotation[] aValue = (Annotation[]) value;
AltAnnotation[] translatedValue = new AltAnnotation[aValue.length];
for (int lcv = 0; lcv < aValue.length; lcv++) {
translatedValue[lcv] = new AnnotationAltAnnotationImpl(aValue[lcv], helper);
}
value = translatedValue;
}
retVal.put(key, value);
}
values = Collections.unmodifiableMap(retVal);
return values;
}
use of org.glassfish.hk2.xml.internal.alt.AltAnnotation in project glassfish-hk2 by eclipse-ee4j.
the class ElementAltMethodImpl method getAnnotations.
/* (non-Javadoc)
* @see org.glassfish.hk2.xml.internal.alt.AltMethod#getAnnotations()
*/
@Override
public synchronized List<AltAnnotation> getAnnotations() {
if (annotations != null) {
return Collections.unmodifiableList(new ArrayList<AltAnnotation>(annotations.values()));
}
Map<String, AltAnnotation> retVal = new LinkedHashMap<String, AltAnnotation>();
for (AnnotationMirror annoMirror : method.getAnnotationMirrors()) {
AnnotationMirrorAltAnnotationImpl addMe = new AnnotationMirrorAltAnnotationImpl(annoMirror, processingEnv);
retVal.put(addMe.annotationType(), addMe);
}
annotations = Collections.unmodifiableMap(retVal);
return Collections.unmodifiableList(new ArrayList<AltAnnotation>(annotations.values()));
}
Aggregations