Java Code Examples for org.springframework.core.convert.TypeDescriptor#collection()
The following examples show how to use
org.springframework.core.convert.TypeDescriptor#collection() .
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: StreamConverter.java From spring-analysis-note with MIT License | 5 votes |
private Object convertToStream(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor streamType) { TypeDescriptor targetCollection = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); List<?> target = (List<?>) this.conversionService.convert(source, sourceType, targetCollection); if (target == null) { target = Collections.emptyList(); } return target.stream(); }
Example 2
Source File: ExtendedDefaultConversionService.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public <S, T> List<T> convert(List<S> collection, Class<S> sourceType, Class<T> targetType) { TypeDescriptor sourceTypeDesc = TypeDescriptor.collection(collection.getClass(), TypeDescriptor.valueOf(sourceType)); TypeDescriptor targetTypeDesc = TypeDescriptor.collection(collection.getClass(), TypeDescriptor.valueOf(targetType)); @SuppressWarnings("unchecked") List<T> returnList = (List<T>) convert(collection, sourceTypeDesc, targetTypeDesc); return returnList; }
Example 3
Source File: UploadServiceImpl.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
private List<PageUploadData> transformListToPageUploadData(List<UploadData> paginatedList) { TypeDescriptor source = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(UploadData.class)); TypeDescriptor target = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(PageUploadData.class)); @SuppressWarnings("unchecked") List<PageUploadData> returnList = (List<PageUploadData>) conversionService.convert(paginatedList, source, target); return returnList; }
Example 4
Source File: SpelKeyGenerator.java From distributed-lock with MIT License | 5 votes |
private List<String> arrayToList(final Object expressionValue) { final TypeDescriptor genericArray = TypeDescriptor.array(TypeDescriptor.valueOf(Object.class)); final TypeDescriptor stringList = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(String.class)); //noinspection unchecked return (List<String>) conversionService.convert(expressionValue, genericArray, stringList); }
Example 5
Source File: SpelKeyGenerator.java From distributed-lock with MIT License | 5 votes |
private List<String> iterableToList(final Object expressionValue) { final TypeDescriptor genericCollection = TypeDescriptor.collection(Collection.class, TypeDescriptor.valueOf(Object.class)); final TypeDescriptor stringList = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(String.class)); //noinspection unchecked return (List<String>) conversionService.convert(expressionValue, genericCollection, stringList); }
Example 6
Source File: StreamConverter.java From java-technology-stack with MIT License | 5 votes |
private Object convertToStream(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor streamType) { TypeDescriptor targetCollection = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); List<?> target = (List<?>) this.conversionService.convert(source, sourceType, targetCollection); if (target == null) { target = Collections.emptyList(); } return target.stream(); }
Example 7
Source File: StreamConverter.java From spring4-understanding with Apache License 2.0 | 4 votes |
private Object convertToStream(Object source, TypeDescriptor sourceType, TypeDescriptor streamType) { TypeDescriptor targetCollection = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); List<?> target = (List<?>) this.conversionService.convert(source, sourceType, targetCollection); return target.stream(); }
Example 8
Source File: StreamConverter.java From spring4-understanding with Apache License 2.0 | 4 votes |
private Object convertFromStream(Stream<?> source, TypeDescriptor streamType, TypeDescriptor targetType) { List<Object> content = source.collect(Collectors.<Object>toList()); TypeDescriptor listType = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); return this.conversionService.convert(content, listType, targetType); }
Example 9
Source File: StreamConverter.java From lams with GNU General Public License v2.0 | 4 votes |
private Object convertToStream(Object source, TypeDescriptor sourceType, TypeDescriptor streamType) { TypeDescriptor targetCollection = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); List<?> target = (List<?>) this.conversionService.convert(source, sourceType, targetCollection); return target.stream(); }
Example 10
Source File: StreamConverter.java From lams with GNU General Public License v2.0 | 4 votes |
private Object convertFromStream(Stream<?> source, TypeDescriptor streamType, TypeDescriptor targetType) { List<Object> content = source.collect(Collectors.<Object>toList()); TypeDescriptor listType = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); return this.conversionService.convert(content, listType, targetType); }
Example 11
Source File: StreamConverter.java From java-technology-stack with MIT License | 4 votes |
@Nullable private Object convertFromStream(@Nullable Stream<?> source, TypeDescriptor streamType, TypeDescriptor targetType) { List<Object> content = (source != null ? source.collect(Collectors.<Object>toList()) : Collections.emptyList()); TypeDescriptor listType = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); return this.conversionService.convert(content, listType, targetType); }
Example 12
Source File: StreamConverter.java From spring-analysis-note with MIT License | 4 votes |
@Nullable private Object convertFromStream(@Nullable Stream<?> source, TypeDescriptor streamType, TypeDescriptor targetType) { List<Object> content = (source != null ? source.collect(Collectors.<Object>toList()) : Collections.emptyList()); TypeDescriptor listType = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor()); return this.conversionService.convert(content, listType, targetType); }
Example 13
Source File: StreamConverter.java From java-technology-stack with MIT License | 2 votes |
/** * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of * the type of the stream elements. * @param elementType the type of the stream elements * @param sourceType the type to convert from */ public boolean matchesToStream(@Nullable TypeDescriptor elementType, TypeDescriptor sourceType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(sourceType, collectionOfElement); }
Example 14
Source File: StreamConverter.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Validate that a {@link Collection} of the elements held within the stream can be * converted to the specified {@code targetType}. * @param elementType the type of the stream elements * @param targetType the type to convert to */ public boolean matchesFromStream(TypeDescriptor elementType, TypeDescriptor targetType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(collectionOfElement, targetType); }
Example 15
Source File: StreamConverter.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of * the type of the stream elements. * @param elementType the type of the stream elements * @param sourceType the type to convert from */ public boolean matchesToStream(TypeDescriptor elementType, TypeDescriptor sourceType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(sourceType, collectionOfElement); }
Example 16
Source File: StreamConverter.java From java-technology-stack with MIT License | 2 votes |
/** * Validate that a {@link Collection} of the elements held within the stream can be * converted to the specified {@code targetType}. * @param elementType the type of the stream elements * @param targetType the type to convert to */ public boolean matchesFromStream(@Nullable TypeDescriptor elementType, TypeDescriptor targetType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(collectionOfElement, targetType); }
Example 17
Source File: StreamConverter.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Validate that a {@link Collection} of the elements held within the stream can be * converted to the specified {@code targetType}. * @param elementType the type of the stream elements * @param targetType the type to convert to */ public boolean matchesFromStream(TypeDescriptor elementType, TypeDescriptor targetType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(collectionOfElement, targetType); }
Example 18
Source File: StreamConverter.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of * the type of the stream elements. * @param elementType the type of the stream elements * @param sourceType the type to convert from */ public boolean matchesToStream(TypeDescriptor elementType, TypeDescriptor sourceType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(sourceType, collectionOfElement); }
Example 19
Source File: StreamConverter.java From spring-analysis-note with MIT License | 2 votes |
/** * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of * the type of the stream elements. * @param elementType the type of the stream elements * @param sourceType the type to convert from */ public boolean matchesToStream(@Nullable TypeDescriptor elementType, TypeDescriptor sourceType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(sourceType, collectionOfElement); }
Example 20
Source File: StreamConverter.java From spring-analysis-note with MIT License | 2 votes |
/** * Validate that a {@link Collection} of the elements held within the stream can be * converted to the specified {@code targetType}. * @param elementType the type of the stream elements * @param targetType the type to convert to */ public boolean matchesFromStream(@Nullable TypeDescriptor elementType, TypeDescriptor targetType) { TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType); return this.conversionService.canConvert(collectionOfElement, targetType); }