Java Code Examples for org.springframework.core.annotation.AnnotationAttributes#entrySet()
The following examples show how to use
org.springframework.core.annotation.AnnotationAttributes#entrySet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodMetadataReadingVisitor.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { if (!this.attributesMap.containsKey(annotationName)) { return null; } MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<String, Object>(); for (AnnotationAttributes annotationAttributes : this.attributesMap.get(annotationName)) { AnnotationAttributes convertedAttributes = AnnotationReadingVisitorUtils.convertClassValues( "method '" + getMethodName() + "'", this.classLoader, annotationAttributes, classValuesAsString); for (Map.Entry<String, Object> entry : convertedAttributes.entrySet()) { allAttributes.add(entry.getKey(), entry.getValue()); } } return allAttributes; }
Example 2
Source File: AnnotationReadingVisitorUtils.java From spring-analysis-note with MIT License | 4 votes |
public static AnnotationAttributes convertClassValues(Object annotatedElement, @Nullable ClassLoader classLoader, AnnotationAttributes original, boolean classValuesAsString) { AnnotationAttributes result = new AnnotationAttributes(original); AnnotationUtils.postProcessAnnotationAttributes(annotatedElement, result, classValuesAsString); for (Map.Entry<String, Object> entry : result.entrySet()) { try { Object value = entry.getValue(); if (value instanceof AnnotationAttributes) { value = convertClassValues( annotatedElement, classLoader, (AnnotationAttributes) value, classValuesAsString); } else if (value instanceof AnnotationAttributes[]) { AnnotationAttributes[] values = (AnnotationAttributes[]) value; for (int i = 0; i < values.length; i++) { values[i] = convertClassValues(annotatedElement, classLoader, values[i], classValuesAsString); } value = values; } else if (value instanceof Type) { value = (classValuesAsString ? ((Type) value).getClassName() : ClassUtils.forName(((Type) value).getClassName(), classLoader)); } else if (value instanceof Type[]) { Type[] array = (Type[]) value; Object[] convArray = (classValuesAsString ? new String[array.length] : new Class<?>[array.length]); for (int i = 0; i < array.length; i++) { convArray[i] = (classValuesAsString ? array[i].getClassName() : ClassUtils.forName(array[i].getClassName(), classLoader)); } value = convArray; } else if (classValuesAsString) { if (value instanceof Class) { value = ((Class<?>) value).getName(); } else if (value instanceof Class[]) { Class<?>[] clazzArray = (Class<?>[]) value; String[] newValue = new String[clazzArray.length]; for (int i = 0; i < clazzArray.length; i++) { newValue[i] = clazzArray[i].getName(); } value = newValue; } } entry.setValue(value); } catch (Throwable ex) { // Class not found - can't resolve class reference in annotation attribute. result.put(entry.getKey(), ex); } } return result; }
Example 3
Source File: AnnotationReadingVisitorUtils.java From java-technology-stack with MIT License | 4 votes |
public static AnnotationAttributes convertClassValues(Object annotatedElement, @Nullable ClassLoader classLoader, AnnotationAttributes original, boolean classValuesAsString) { AnnotationAttributes result = new AnnotationAttributes(original); AnnotationUtils.postProcessAnnotationAttributes(annotatedElement, result, classValuesAsString); for (Map.Entry<String, Object> entry : result.entrySet()) { try { Object value = entry.getValue(); if (value instanceof AnnotationAttributes) { value = convertClassValues( annotatedElement, classLoader, (AnnotationAttributes) value, classValuesAsString); } else if (value instanceof AnnotationAttributes[]) { AnnotationAttributes[] values = (AnnotationAttributes[]) value; for (int i = 0; i < values.length; i++) { values[i] = convertClassValues(annotatedElement, classLoader, values[i], classValuesAsString); } value = values; } else if (value instanceof Type) { value = (classValuesAsString ? ((Type) value).getClassName() : ClassUtils.forName(((Type) value).getClassName(), classLoader)); } else if (value instanceof Type[]) { Type[] array = (Type[]) value; Object[] convArray = (classValuesAsString ? new String[array.length] : new Class<?>[array.length]); for (int i = 0; i < array.length; i++) { convArray[i] = (classValuesAsString ? array[i].getClassName() : ClassUtils.forName(array[i].getClassName(), classLoader)); } value = convArray; } else if (classValuesAsString) { if (value instanceof Class) { value = ((Class<?>) value).getName(); } else if (value instanceof Class[]) { Class<?>[] clazzArray = (Class<?>[]) value; String[] newValue = new String[clazzArray.length]; for (int i = 0; i < clazzArray.length; i++) { newValue[i] = clazzArray[i].getName(); } value = newValue; } } entry.setValue(value); } catch (Throwable ex) { // Class not found - can't resolve class reference in annotation attribute. result.put(entry.getKey(), ex); } } return result; }
Example 4
Source File: AnnotationReadingVisitorUtils.java From lams with GNU General Public License v2.0 | 4 votes |
public static AnnotationAttributes convertClassValues(Object annotatedElement, ClassLoader classLoader, AnnotationAttributes original, boolean classValuesAsString) { if (original == null) { return null; } AnnotationAttributes result = new AnnotationAttributes(original); AnnotationUtils.postProcessAnnotationAttributes(annotatedElement, result, classValuesAsString); for (Map.Entry<String, Object> entry : result.entrySet()) { try { Object value = entry.getValue(); if (value instanceof AnnotationAttributes) { value = convertClassValues( annotatedElement, classLoader, (AnnotationAttributes) value, classValuesAsString); } else if (value instanceof AnnotationAttributes[]) { AnnotationAttributes[] values = (AnnotationAttributes[]) value; for (int i = 0; i < values.length; i++) { values[i] = convertClassValues(annotatedElement, classLoader, values[i], classValuesAsString); } value = values; } else if (value instanceof Type) { value = (classValuesAsString ? ((Type) value).getClassName() : classLoader.loadClass(((Type) value).getClassName())); } else if (value instanceof Type[]) { Type[] array = (Type[]) value; Object[] convArray = (classValuesAsString ? new String[array.length] : new Class<?>[array.length]); for (int i = 0; i < array.length; i++) { convArray[i] = (classValuesAsString ? array[i].getClassName() : classLoader.loadClass(array[i].getClassName())); } value = convArray; } else if (classValuesAsString) { if (value instanceof Class) { value = ((Class<?>) value).getName(); } else if (value instanceof Class[]) { Class<?>[] clazzArray = (Class<?>[]) value; String[] newValue = new String[clazzArray.length]; for (int i = 0; i < clazzArray.length; i++) { newValue[i] = clazzArray[i].getName(); } value = newValue; } } entry.setValue(value); } catch (Throwable ex) { // Class not found - can't resolve class reference in annotation attribute. result.put(entry.getKey(), ex); } } return result; }
Example 5
Source File: AnnotationReadingVisitorUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
public static AnnotationAttributes convertClassValues(ClassLoader classLoader, AnnotationAttributes original, boolean classValuesAsString) { if (original == null) { return null; } AnnotationAttributes result = new AnnotationAttributes(original.size()); for (Map.Entry<String, Object> entry : original.entrySet()) { try { Object value = entry.getValue(); if (value instanceof AnnotationAttributes) { value = convertClassValues(classLoader, (AnnotationAttributes) value, classValuesAsString); } else if (value instanceof AnnotationAttributes[]) { AnnotationAttributes[] values = (AnnotationAttributes[]) value; for (int i = 0; i < values.length; i++) { values[i] = convertClassValues(classLoader, values[i], classValuesAsString); } } else if (value instanceof Type) { value = (classValuesAsString ? ((Type) value).getClassName() : classLoader.loadClass(((Type) value).getClassName())); } else if (value instanceof Type[]) { Type[] array = (Type[]) value; Object[] convArray = (classValuesAsString ? new String[array.length] : new Class<?>[array.length]); for (int i = 0; i < array.length; i++) { convArray[i] = (classValuesAsString ? array[i].getClassName() : classLoader.loadClass(array[i].getClassName())); } value = convArray; } else if (classValuesAsString) { if (value instanceof Class) { value = ((Class<?>) value).getName(); } else if (value instanceof Class[]) { Class<?>[] clazzArray = (Class[]) value; String[] newValue = new String[clazzArray.length]; for (int i = 0; i < clazzArray.length; i++) { newValue[i] = clazzArray[i].getName(); } value = newValue; } } result.put(entry.getKey(), value); } catch (Exception ex) { // Class not found - can't resolve class reference in annotation attribute. result.put(entry.getKey(), ex); } } return result; }