Java Code Examples for org.springframework.core.ResolvableType#forField()
The following examples show how to use
org.springframework.core.ResolvableType#forField() .
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: DependencyDescriptor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build a ResolvableType object for the wrapped parameter/field. * @since 4.0 */ public ResolvableType getResolvableType() { ResolvableType resolvableType = this.resolvableType; if (resolvableType == null) { resolvableType = (this.field != null ? ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) : ResolvableType.forMethodParameter(this.methodParameter)); this.resolvableType = resolvableType; } return resolvableType; }
Example 2
Source File: SerializableAnnotationBeanPostProcessor.java From jdal with Apache License 2.0 | 5 votes |
private ResolvableType getResolvableType(AnnotatedElement element) { if (element instanceof Field) return ResolvableType.forField((Field) element); else if (element instanceof Method) return ResolvableType.forMethodParameter( new MethodParameter((Method) element, 0)); throw new IllegalArgumentException("SerializableProxy annotation should only be applied on types" + ", fields or methods but was found in [" + element.toString() + "]"); }
Example 3
Source File: CarHandler.java From tutorials with MIT License | 5 votes |
public List<Vehicle> getVehicles() throws NoSuchFieldException { ResolvableType vehiclesType = ResolvableType.forField(getClass().getDeclaredField("vehicles")); System.out.println(vehiclesType); ResolvableType type = vehiclesType.getGeneric(); System.out.println(type); Class<?> aClass = type.resolve(); System.out.println(aClass); return this.vehicles; }
Example 4
Source File: TypeDescriptor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new type descriptor from a {@link Field}. * <p>Use this constructor when a source or target conversion point is a field. * @param field the field */ public TypeDescriptor(Field field) { Assert.notNull(field, "Field must not be null"); this.resolvableType = ResolvableType.forField(field); this.type = this.resolvableType.resolve(field.getType()); this.annotations = nullSafeAnnotations(field.getAnnotations()); }
Example 5
Source File: AbstractApplicationEventListenerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected ResolvableType getGenericApplicationEventType(String fieldName) { try { return ResolvableType.forField(TestEvents.class.getField(fieldName)); } catch (NoSuchFieldException e) { throw new IllegalStateException("No such field on Events '" + fieldName + "'"); } }
Example 6
Source File: AbstractApplicationEventListenerTests.java From spring-analysis-note with MIT License | 5 votes |
protected ResolvableType getGenericApplicationEventType(String fieldName) { try { return ResolvableType.forField(TestEvents.class.getField(fieldName)); } catch (NoSuchFieldException ex) { throw new IllegalStateException("No such field on Events '" + fieldName + "'"); } }
Example 7
Source File: ProtoFileResourceUtils.java From raptor with Apache License 2.0 | 5 votes |
private static Set<ProtoFileInfo> findProtoFilesByMessage(Class<?> messageClass, Set<Class<?>> founds, ClassLoader classLoader) { Set<ProtoFileInfo> results = new HashSet<>(); ProtoFileInfo protoFileInfo = findMessageProtoFile(messageClass, classLoader); if (protoFileInfo != null && !founds.contains(messageClass)) { results.add(protoFileInfo); founds.add(messageClass); Field[] fields = messageClass.getDeclaredFields(); for (Field field : fields) { Class<?> fieldType = field.getType(); RaptorMessage annotation = AnnotationUtils.findAnnotation(fieldType, RaptorMessage.class); ResolvableType resolvableType = ResolvableType.forField(field); if (annotation != null) { Set<ProtoFileInfo> filedMessageProtoFiles = findProtoFilesByMessage(fieldType, founds, classLoader); results.addAll(filedMessageProtoFiles); } else if (List.class.isAssignableFrom(fieldType)) { ResolvableType genericType = resolvableType.getGeneric(0); results.addAll(findProtoFilesByMessage(genericType.getRawClass(), founds, classLoader)); } else if (Map.class.isAssignableFrom(fieldType)) { ResolvableType keyType = resolvableType.getGeneric(0); ResolvableType valueType = resolvableType.getGeneric(1); results.addAll(findProtoFilesByMessage(keyType.getRawClass(), founds, classLoader)); results.addAll(findProtoFilesByMessage(valueType.getRawClass(), founds, classLoader)); } } } return results; }
Example 8
Source File: DependencyDescriptor.java From java-technology-stack with MIT License | 5 votes |
/** * Build a {@link ResolvableType} object for the wrapped parameter/field. * @since 4.0 */ public ResolvableType getResolvableType() { ResolvableType resolvableType = this.resolvableType; if (resolvableType == null) { resolvableType = (this.field != null ? ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) : ResolvableType.forMethodParameter(obtainMethodParameter())); this.resolvableType = resolvableType; } return resolvableType; }
Example 9
Source File: AbstractApplicationEventListenerTests.java From java-technology-stack with MIT License | 5 votes |
protected ResolvableType getGenericApplicationEventType(String fieldName) { try { return ResolvableType.forField(TestEvents.class.getField(fieldName)); } catch (NoSuchFieldException ex) { throw new IllegalStateException("No such field on Events '" + fieldName + "'"); } }
Example 10
Source File: DependencyDescriptor.java From spring-analysis-note with MIT License | 5 votes |
/** * Build a {@link ResolvableType} object for the wrapped parameter/field. * @since 4.0 */ public ResolvableType getResolvableType() { ResolvableType resolvableType = this.resolvableType; if (resolvableType == null) { resolvableType = (this.field != null ? ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) : ResolvableType.forMethodParameter(obtainMethodParameter())); this.resolvableType = resolvableType; } return resolvableType; }
Example 11
Source File: DirectFieldAccessor.java From java-technology-stack with MIT License | 4 votes |
@Override public ResolvableType getResolvableType() { return ResolvableType.forField(this.field); }
Example 12
Source File: TypeDescriptor.java From java-technology-stack with MIT License | 4 votes |
/** * Create a new type descriptor from a {@link Field}. * <p>Use this constructor when a source or target conversion point is a field. * @param field the field */ public TypeDescriptor(Field field) { this.resolvableType = ResolvableType.forField(field); this.type = this.resolvableType.resolve(field.getType()); this.annotatedElement = new AnnotatedElementAdapter(field.getAnnotations()); }
Example 13
Source File: DirectFieldAccessor.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public ResolvableType getResolvableType() { return ResolvableType.forField(this.field); }
Example 14
Source File: TypeDescriptor.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Create a new type descriptor from a {@link Field}. * <p>Use this constructor when a source or target conversion point is a field. * @param field the field */ public TypeDescriptor(Field field) { this.resolvableType = ResolvableType.forField(field); this.type = this.resolvableType.resolve(field.getType()); this.annotatedElement = new AnnotatedElementAdapter(field.getAnnotations()); }
Example 15
Source File: DependencyDescriptor.java From blog_demos with Apache License 2.0 | 4 votes |
/** * Build a ResolvableType object for the wrapped parameter/field. */ public ResolvableType getResolvableType() { return (this.field != null ? ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) : ResolvableType.forMethodParameter(this.methodParameter)); }
Example 16
Source File: DirectFieldAccessor.java From spring-analysis-note with MIT License | 4 votes |
@Override public ResolvableType getResolvableType() { return ResolvableType.forField(this.field); }
Example 17
Source File: DependencyDescriptor.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Build a ResolvableType object for the wrapped parameter/field. */ public ResolvableType getResolvableType() { return (this.field != null ? ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) : ResolvableType.forMethodParameter(this.methodParameter)); }
Example 18
Source File: DirectFieldAccessor.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public ResolvableType getResolvableType() { return ResolvableType.forField(this.field); }
Example 19
Source File: TypeDescriptor.java From spring-analysis-note with MIT License | 4 votes |
/** * Create a new type descriptor from a {@link Field}. * <p>Use this constructor when a source or target conversion point is a field. * @param field the field */ public TypeDescriptor(Field field) { this.resolvableType = ResolvableType.forField(field); this.type = this.resolvableType.resolve(field.getType()); this.annotatedElement = new AnnotatedElementAdapter(field.getAnnotations()); }