org.springframework.core.convert.TypeDescriptor#collection ( )源码实例Demo

下面列出了org.springframework.core.convert.TypeDescriptor#collection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-analysis-note   文件: StreamConverter.java
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();
}
 
@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;
}
 
源代码3 项目: openemm   文件: UploadServiceImpl.java
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;
  }
 
源代码4 项目: java-technology-stack   文件: StreamConverter.java
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();
}
 
源代码5 项目: distributed-lock   文件: SpelKeyGenerator.java
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);
}
 
源代码6 项目: distributed-lock   文件: SpelKeyGenerator.java
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);
}
 
源代码7 项目: spring-analysis-note   文件: StreamConverter.java
@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);
}
 
源代码8 项目: java-technology-stack   文件: StreamConverter.java
@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);
}
 
源代码9 项目: lams   文件: StreamConverter.java
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);
}
 
源代码10 项目: lams   文件: StreamConverter.java
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();
}
 
源代码11 项目: spring4-understanding   文件: StreamConverter.java
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);
}
 
源代码12 项目: spring4-understanding   文件: StreamConverter.java
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();
}
 
源代码13 项目: spring-analysis-note   文件: StreamConverter.java
/**
 * 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);
}
 
源代码14 项目: spring-analysis-note   文件: StreamConverter.java
/**
 * 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);
}
 
源代码15 项目: java-technology-stack   文件: StreamConverter.java
/**
 * 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);
}
 
源代码16 项目: java-technology-stack   文件: StreamConverter.java
/**
 * 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);
}
 
源代码17 项目: lams   文件: StreamConverter.java
/**
 * 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);
}
 
源代码18 项目: lams   文件: StreamConverter.java
/**
 * 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);
}
 
源代码19 项目: spring4-understanding   文件: StreamConverter.java
/**
 * 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);
}
 
源代码20 项目: spring4-understanding   文件: StreamConverter.java
/**
 * 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);
}