Java Code Examples for org.springframework.core.convert.TypeDescriptor#getResolvableType()
The following examples show how to use
org.springframework.core.convert.TypeDescriptor#getResolvableType() .
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: ObjectToOptionalConverter.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return Optional.empty(); } else if (source instanceof Optional) { return source; } else if (targetType.getResolvableType() != null) { Object target = this.conversionService.convert(source, sourceType, new GenericTypeDescriptor(targetType)); if (target == null || (target.getClass().isArray() && Array.getLength(target) == 0) || (target instanceof Collection && ((Collection) target).isEmpty())) { return Optional.empty(); } return Optional.of(target); } else { return Optional.of(source); } }
Example 2
Source File: ObjectToOptionalConverter.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return Optional.empty(); } else if (source instanceof Optional) { return source; } else if (targetType.getResolvableType() == null) { return Optional.of(source); } else { Object target = this.conversionService.convert(source, sourceType, new GenericTypeDescriptor(targetType)); return Optional.ofNullable(target); } }
Example 3
Source File: GenericConversionService.java From spring-analysis-note with MIT License | 5 votes |
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { // Check raw type first... if (this.typeInfo.getTargetType() != targetType.getObjectType()) { return false; } // Full check for complex generic type match required? ResolvableType rt = targetType.getResolvableType(); if (!(rt.getType() instanceof Class) && !rt.isAssignableFrom(this.targetType) && !this.targetType.hasUnresolvableGenerics()) { return false; } return !(this.converter instanceof ConditionalConverter) || ((ConditionalConverter) this.converter).matches(sourceType, targetType); }
Example 4
Source File: GenericConversionService.java From java-technology-stack with MIT License | 5 votes |
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { // Check raw type first... if (this.typeInfo.getTargetType() != targetType.getObjectType()) { return false; } // Full check for complex generic type match required? ResolvableType rt = targetType.getResolvableType(); if (!(rt.getType() instanceof Class) && !rt.isAssignableFrom(this.targetType) && !this.targetType.hasUnresolvableGenerics()) { return false; } return !(this.converter instanceof ConditionalConverter) || ((ConditionalConverter) this.converter).matches(sourceType, targetType); }
Example 5
Source File: ObjectToOptionalConverter.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { if (targetType.getResolvableType() != null) { return this.conversionService.canConvert(sourceType, new GenericTypeDescriptor(targetType)); } else { return true; } }
Example 6
Source File: GenericConversionService.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { // Check raw type first... if (this.typeInfo.getTargetType() != targetType.getObjectType()) { return false; } // Full check for complex generic type match required? ResolvableType rt = targetType.getResolvableType(); if (!(rt.getType() instanceof Class) && !rt.isAssignableFrom(this.targetType) && !this.targetType.hasUnresolvableGenerics()) { return false; } return !(this.converter instanceof ConditionalConverter) || ((ConditionalConverter) this.converter).matches(sourceType, targetType); }
Example 7
Source File: ObjectToOptionalConverter.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { if (targetType.getResolvableType() != null) { return this.conversionService.canConvert(sourceType, new GenericTypeDescriptor(targetType)); } else { return true; } }
Example 8
Source File: GenericConversionService.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { // Check raw type first... if (this.typeInfo.getTargetType() != targetType.getObjectType()) { return false; } // Full check for complex generic type match required? ResolvableType rt = targetType.getResolvableType(); if (!(rt.getType() instanceof Class) && !rt.isAssignableFrom(this.targetType) && !this.targetType.hasUnresolvableGenerics()) { return false; } return !(this.converter instanceof ConditionalConverter) || ((ConditionalConverter) this.converter).matches(sourceType, targetType); }