当前位置: 首页>>代码示例>>Java>>正文


Java TypeInformation类代码示例

本文整理汇总了Java中org.springframework.data.util.TypeInformation的典型用法代码示例。如果您正苦于以下问题:Java TypeInformation类的具体用法?Java TypeInformation怎么用?Java TypeInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TypeInformation类属于org.springframework.data.util包,在下文中一共展示了TypeInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BasicVaultPersistentEntity

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * Creates new {@link BasicVaultPersistentEntity}.
 *
 * @param information must not be {@literal null}.
 * @param fallbackKeySpaceResolver can be {@literal null}.
 */
public BasicVaultPersistentEntity(TypeInformation<T> information,
		KeySpaceResolver fallbackKeySpaceResolver) {
	super(information, fallbackKeySpaceResolver);

	Secret annotation = findAnnotation(Secret.class);

	String keyspace = super.getKeySpace();
	String secretBackend = "secret";

	if (annotation != null) {
		if (StringUtils.hasText(annotation.backend())) {
			secretBackend = annotation.backend();
		}
	}

	this.secretBackend = secretBackend;
	this.keyspace = String.format("%s/%s", secretBackend, keyspace);
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:25,代码来源:BasicVaultPersistentEntity.java

示例2: readValue

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
@Nullable
@SuppressWarnings("unchecked")
private <T> T readValue(Object value, TypeInformation<?> type) {

	Class<?> rawType = type.getType();

	if (conversions.hasCustomReadTarget(value.getClass(), rawType)) {
		return (T) conversionService.convert(value, rawType);
	}
	else if (value instanceof List) {
		return (T) readCollectionOrArray(type, (List) value);
	}
	else if (value instanceof Map) {
		return (T) read(type, (Map) value);
	}
	else {
		return (T) getPotentiallyConvertedSimpleRead(value, rawType);
	}
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:20,代码来源:MappingVaultConverter.java

示例3: write

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
@Override
public void write(Object source, SecretDocument sink) {

	Class<?> entityType = ClassUtils.getUserClass(source.getClass());
	TypeInformation<? extends Object> type = ClassTypeInformation.from(entityType);

	SecretDocumentAccessor documentAccessor = new SecretDocumentAccessor(sink);

	writeInternal(source, documentAccessor, type);

	boolean handledByCustomConverter = conversions.hasCustomWriteTarget(entityType,
			SecretDocument.class);
	if (!handledByCustomConverter) {
		typeMapper.writeType(type, sink.getBody());
	}
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:17,代码来源:MappingVaultConverter.java

示例4: extractTypeInfo

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * Obtains the domain type information from the given method parameter. Will
 * favor an explicitly registered on through
 * {@link QuerydslPredicate#root()} but use the actual type of the method's
 * return type as fallback.
 * 
 * @param parameter
 *            must not be {@literal null}.
 * @return
 */
static TypeInformation<?> extractTypeInfo(MethodParameter parameter) {

	QuerydslPredicate annotation = parameter.getParameterAnnotation(QuerydslPredicate.class);

	if (annotation != null && !Object.class.equals(annotation.root())) {
		return ClassTypeInformation.from(annotation.root());
	}

	Class<?> containingClass = parameter.getContainingClass();
	if (ClassUtils.isAssignable(EntityController.class, containingClass)) {
		ResolvableType resolvableType = ResolvableType.forClass(containingClass);
		return ClassTypeInformation.from(resolvableType.as(EntityController.class).getGeneric(0).resolve());
	}

	return detectDomainType(ClassTypeInformation.fromReturnTypeOf(parameter.getMethod()));
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:27,代码来源:DefaultPredicateArgumentResolver.java

示例5: detectDomainType

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
private static TypeInformation<?> detectDomainType(TypeInformation<?> source) {

		if (source.getTypeArguments().isEmpty()) {
			return source;
		}

		TypeInformation<?> actualType = source.getActualType();

		if (source != actualType) {
			return detectDomainType(actualType);
		}

		if (source instanceof Iterable) {
			return source;
		}

		return detectDomainType(source.getComponentType());
	}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:19,代码来源:DefaultPredicateArgumentResolver.java

示例6: writeCollection

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * @param keyspace
 * @param path
 * @param values
 * @param typeHint
 * @param sink
 */
private void writeCollection(String keyspace, String path, Collection<?> values, TypeInformation<?> typeHint,
		RedisData sink) {

	if (values == null) {
		return;
	}

	int i = 0;
	for (Object o : values) {

		String currentPath = path + ".[" + i + "]";

		if (conversionService.canConvert(o.getClass(), byte[].class)) {
			sink.addDataEntry(toBytes(currentPath), toBytes(o));
		} else {
			writeInternal(keyspace, currentPath, o, typeHint, sink);
		}
		i++;
	}
}
 
开发者ID:christophstrobl,项目名称:spring-data-keyvalue-redis,代码行数:28,代码来源:MappingRedisConverter.java

示例7: read

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <S extends Object> S read(TypeInformation<S> targetTypeInformation, Map<String, ?> source) {
	if (source == null) {
		return null;
	}
	Assert.notNull(targetTypeInformation);
	Class<S> rawType = targetTypeInformation.getType();

	// in case there's a custom conversion for the document
	if (hasCustomReadTarget(source.getClass(), rawType)) {
		return convert(source, rawType);
	}

	SolrPersistentEntity<S> entity = (SolrPersistentEntity<S>) mappingContext.getPersistentEntity(rawType);
	return read(entity, source, null);
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:17,代码来源:MappingSolrConverter.java

示例8: readCollection

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
private Object readCollection(Collection<?> source, TypeInformation<?> type, Object parent) {
	Assert.notNull(type);

	Class<?> collectionType = type.getType();
	if (CollectionUtils.isEmpty(source)) {
		return source;
	}

	collectionType = Collection.class.isAssignableFrom(collectionType) ? collectionType : List.class;

	Collection<Object> items;
	if (type.getType().isArray()) {
		items = new ArrayList<Object>();
	} else {
		items = CollectionFactory.createCollection(collectionType, source.size());
	}

	TypeInformation<?> componentType = type.getComponentType();

	Iterator<?> it = source.iterator();
	while (it.hasNext()) {
		items.add(readValue(it.next(), componentType, parent));
	}

	return type.getType().isArray() ? convertItemsToArrayOfType(type, items) : items;
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:27,代码来源:MappingSolrConverter.java

示例9: mapColumns

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * @param properties properties of array/collection types, must not be {@literal null}.
 * @return list of columns of crate type array
 * @throws {@link InvalidCrateApiUsageException}
 */
public List<Column> mapColumns(Set<CratePersistentProperty> properties) {
	
	List<Column> columns = new LinkedList<>();
	
	for(CratePersistentProperty property : properties) {
		
		TypeInformation<?> typeInformation = from(property.getComponentType());
		// safety check
		if(property.isCollectionLike() && typeInformation.isMap()) {
			
			// could be a list or an array
			TypeInformation<?> actualType = property.getTypeInformation().getActualType();					
			// get the map's key type
			Class<?> componentType = actualType.getTypeArguments().get(0).getType();					
			
			checkMapKey(componentType);
			
			columns.add(createColumn(property));
		}
	}
	
	return columns;
}
 
开发者ID:KPTechnologyLab,项目名称:spring-data-crate,代码行数:29,代码来源:EntityColumnMapper.java

示例10: writeCollectionInternal

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
   * Helper method to write the internal collection.
   *
   * @param source the source object.
   * @param target the target document.
   * @param type the type information for the document.
   * @return the created crate list.
   */
private CrateArray writeCollectionInternal(final Collection<?> source, final CrateArray target, final TypeInformation<?> type) {
	
	TypeInformation<?> componentType = type == null ? null : type.getComponentType();

    for(Object element : source) {
    	
    	validateCollectionLikeElement(element);
    	
    	Class<?> elementType = element == null ? null : element.getClass();
    	
    	if(elementType == null || conversions.isSimpleType(elementType)) {
    		target.add(element);
    	}else {
    		CrateDocument document = new CrateDocument();
    		writeInternal(element, document, componentType);
    		target.add(document);
    	}
    }
    
    return target;
}
 
开发者ID:KPTechnologyLab,项目名称:spring-data-crate,代码行数:30,代码来源:MappingCrateConverter.java

示例11: readValue

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * Helper method to read the value based on the value type.
 *
 * @param value the value to convert.
 * @param type the type information.
 * @param parent the optional parent.
 * @param <R> the target type.
 * @return the converted object.
 */
@SuppressWarnings("unchecked")
private <R> R readValue(Object value, TypeInformation<?> type, Object parent) {
 
 Class<?> rawType = type.getType();
 
 if(conversions.hasCustomReadTarget(value.getClass(), rawType)) {
  return (R) conversionService.convert(value, rawType);			  
 }else if(value instanceof CrateDocument) {
  return (R) read(type, (CrateDocument) value, parent);
 }else if(value instanceof CrateArray) {
  return (R) readCollection(type, (CrateArray) value, parent);
 } else {
  return (R) getPotentiallyConvertedSimpleRead(value, rawType);
 }
}
 
开发者ID:KPTechnologyLab,项目名称:spring-data-crate,代码行数:25,代码来源:MappingCrateConverter.java

示例12: toCrateDocument

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * 
 * @param root container for the converted payload
 * @param payload value to be converted to {@link CrateDocument}
 */
@SuppressWarnings("unchecked")
private void toCrateDocument(CrateDocument root, Object payload) {
	
	Map<String, Object> map = (Map<String, Object>)payload;
	
	for(Entry<String, Object> entry : map.entrySet()) {
		
		TypeInformation<?> type = getTypeInformation(entry.getValue().getClass());
		
		if(type.isMap()) {
			CrateDocument document = new CrateDocument();
			toCrateDocument(document, entry.getValue());
			logger.debug("converted '{}' to CrateDocument", entry.getKey());
			root.put(entry.getKey(), document);
		}else if(type.isCollectionLike()) {
			CrateArray array = new CrateArray();
			toCrateArray(array, entry.getValue());
			logger.debug("converted '{}' to CrateArray", entry.getKey());
			root.put(entry.getKey(), array);
		}else {
			// simple type
			root.put(entry.getKey(), entry.getValue());
		}
	}
}
 
开发者ID:KPTechnologyLab,项目名称:spring-data-crate,代码行数:31,代码来源:CrateDocumentConverter.java

示例13: toCrateArray

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
/**
 * Nesting Array or Collection types is not supported by crate. It is safe to assume that the payload
 * will contain either a Map or a primitive type. Map types will be converted to {@link CrateDocument}
 * while simple types will be added without any conversion
 * @param array {@link CrateArray} for adding either Map or Simple types
 * @param payload containing either a Map or primitive type.
 */
@SuppressWarnings("unchecked")
private void toCrateArray(CrateArray array, Object payload) {
	
	Collection<Object> objects = (Collection<Object>)(payload.getClass().isArray() ? asList((Object[])payload) : payload);
	
	for(Object object : objects) {
		
		TypeInformation<?> type = getTypeInformation(object.getClass());
		
		if(type.isMap()) {
			CrateDocument document = new CrateDocument();
			toCrateDocument(document, object);
			array.add(document);
		}else {
			array.add(object);
		}
	}
}
 
开发者ID:KPTechnologyLab,项目名称:spring-data-crate,代码行数:26,代码来源:CrateDocumentConverter.java

示例14: write

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void write(Object source, @SuppressWarnings("rawtypes") Map target) {
	if (source == null) {
		return;
	}

	if (hasCustomWriteTarget(source.getClass(), SolrInputDocument.class)
			&& canConvert(source.getClass(), SolrInputDocument.class)) {
		SolrInputDocument convertedDocument = convert(source, SolrInputDocument.class);
		target.putAll(convertedDocument);
		return;

	}

	TypeInformation<? extends Object> type = ClassTypeInformation.from(source.getClass());
	write(type, source, target);
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:19,代码来源:MappingSolrConverter.java

示例15: readValue

import org.springframework.data.util.TypeInformation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T readValue(Object value, TypeInformation<?> type, Object parent) {
	if (value == null) {
		return null;
	}

	Assert.notNull(type);
	Class<?> rawType = type.getType();
	if (hasCustomReadTarget(value.getClass(), rawType)) {
		return (T) convert(value, rawType);
	}

	Object documentValue = null;
	if (value instanceof SolrInputField) {
		documentValue = ((SolrInputField) value).getValue();
	} else {
		documentValue = value;
	}

	if (documentValue instanceof Collection) {
		return (T) readCollection((Collection<?>) documentValue, type, parent);
	} else if (canConvert(documentValue.getClass(), rawType)) {
		return (T) convert(documentValue, rawType);
	}
	return (T) documentValue;
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:27,代码来源:MappingSolrConverter.java


注:本文中的org.springframework.data.util.TypeInformation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。