本文整理了Java中org.springframework.core.convert.TypeDescriptor.getRelatedIfResolvable()
方法的一些代码示例,展示了TypeDescriptor.getRelatedIfResolvable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeDescriptor.getRelatedIfResolvable()
方法的具体详情如下:
包路径:org.springframework.core.convert.TypeDescriptor
类名称:TypeDescriptor
方法名:getRelatedIfResolvable
暂无
代码示例来源:origin: spring-projects/spring-framework
@Nullable
private static TypeDescriptor nested(TypeDescriptor typeDescriptor, int nestingLevel) {
ResolvableType nested = typeDescriptor.resolvableType;
for (int i = 0; i < nestingLevel; i++) {
if (Object.class == nested.getType()) {
// Could be a collection type but we don't know about its element type,
// so let's just assume there is an element type of type Object...
}
else {
nested = nested.getNested(2);
}
}
if (nested == ResolvableType.NONE) {
return null;
}
return getRelatedIfResolvable(typeDescriptor, nested);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* If this type is a {@link Map} and its key type is parameterized,
* returns the map's key type. If the Map's key type is not parameterized,
* returns {@code null} indicating the key type is not declared.
* @return the Map key type, or {@code null} if this type is a Map
* but its key type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapKeyTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(0));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* If this type is a {@link Map} and its value type is parameterized,
* returns the map's value type.
* <p>If the Map's value type is not parameterized, returns {@code null}
* indicating the value type is not declared.
* @return the Map value type, or {@code null} if this type is a Map
* but its value type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapValueTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(1));
}
代码示例来源:origin: org.springframework/spring-core
@Nullable
private static TypeDescriptor nested(TypeDescriptor typeDescriptor, int nestingLevel) {
ResolvableType nested = typeDescriptor.resolvableType;
for (int i = 0; i < nestingLevel; i++) {
if (Object.class == nested.getType()) {
// Could be a collection type but we don't know about its element type,
// so let's just assume there is an element type of type Object...
}
else {
nested = nested.getNested(2);
}
}
if (nested == ResolvableType.NONE) {
return null;
}
return getRelatedIfResolvable(typeDescriptor, nested);
}
代码示例来源:origin: org.springframework/spring-core
/**
* If this type is a {@link Map} and its key type is parameterized,
* returns the map's key type. If the Map's key type is not parameterized,
* returns {@code null} indicating the key type is not declared.
* @return the Map key type, or {@code null} if this type is a Map
* but its key type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapKeyTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(0));
}
代码示例来源:origin: org.springframework/spring-core
/**
* If this type is a {@link Map} and its value type is parameterized,
* returns the map's value type.
* <p>If the Map's value type is not parameterized, returns {@code null}
* indicating the value type is not declared.
* @return the Map value type, or {@code null} if this type is a Map
* but its value type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapValueTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(1));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* If this type is an array, returns the array's component type.
* If this type is a {@code Stream}, returns the stream's component type.
* If this type is a {@link Collection} and it is parameterized, returns the Collection's element type.
* If the Collection is not parameterized, returns {@code null} indicating the element type is not declared.
* @return the array component type or Collection element type, or {@code null} if this type is a
* Collection but its element type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Collection} or array type
*/
@Nullable
public TypeDescriptor getElementTypeDescriptor() {
if (getResolvableType().isArray()) {
return new TypeDescriptor(getResolvableType().getComponentType(), null, getAnnotations());
}
if (Stream.class.isAssignableFrom(getType())) {
return getRelatedIfResolvable(this, getResolvableType().as(Stream.class).getGeneric(0));
}
return getRelatedIfResolvable(this, getResolvableType().asCollection().getGeneric(0));
}
代码示例来源:origin: org.springframework/spring-core
/**
* If this type is an array, returns the array's component type.
* If this type is a {@code Stream}, returns the stream's component type.
* If this type is a {@link Collection} and it is parameterized, returns the Collection's element type.
* If the Collection is not parameterized, returns {@code null} indicating the element type is not declared.
* @return the array component type or Collection element type, or {@code null} if this type is a
* Collection but its element type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Collection} or array type
*/
@Nullable
public TypeDescriptor getElementTypeDescriptor() {
if (getResolvableType().isArray()) {
return new TypeDescriptor(getResolvableType().getComponentType(), null, getAnnotations());
}
if (Stream.class.isAssignableFrom(getType())) {
return getRelatedIfResolvable(this, getResolvableType().as(Stream.class).getGeneric(0));
}
return getRelatedIfResolvable(this, getResolvableType().asCollection().getGeneric(0));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
@Nullable
private static TypeDescriptor nested(TypeDescriptor typeDescriptor, int nestingLevel) {
ResolvableType nested = typeDescriptor.resolvableType;
for (int i = 0; i < nestingLevel; i++) {
if (Object.class == nested.getType()) {
// Could be a collection type but we don't know about its element type,
// so let's just assume there is an element type of type Object...
}
else {
nested = nested.getNested(2);
}
}
if (nested == ResolvableType.NONE) {
return null;
}
return getRelatedIfResolvable(typeDescriptor, nested);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* If this type is a {@link Map} and its key type is parameterized,
* returns the map's key type. If the Map's key type is not parameterized,
* returns {@code null} indicating the key type is not declared.
* @return the Map key type, or {@code null} if this type is a Map
* but its key type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapKeyTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(0));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* If this type is a {@link Map} and its value type is parameterized,
* returns the map's value type.
* <p>If the Map's value type is not parameterized, returns {@code null}
* indicating the value type is not declared.
* @return the Map value type, or {@code null} if this type is a Map
* but its value type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapValueTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(1));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* If this type is a {@link Map} and its key type is parameterized,
* returns the map's key type. If the Map's key type is not parameterized,
* returns {@code null} indicating the key type is not declared.
* @return the Map key type, or {@code null} if this type is a Map
* but its key type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapKeyTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(0));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* If this type is a {@link Map} and its value type is parameterized,
* returns the map's value type.
* <p>If the Map's value type is not parameterized, returns {@code null}
* indicating the value type is not declared.
* @return the Map value type, or {@code null} if this type is a Map
* but its value type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Nullable
public TypeDescriptor getMapValueTypeDescriptor() {
Assert.state(isMap(), "Not a [java.util.Map]");
return getRelatedIfResolvable(this, getResolvableType().asMap().getGeneric(1));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* If this type is an array, returns the array's component type.
* If this type is a {@code Stream}, returns the stream's component type.
* If this type is a {@link Collection} and it is parameterized, returns the Collection's element type.
* If the Collection is not parameterized, returns {@code null} indicating the element type is not declared.
* @return the array component type or Collection element type, or {@code null} if this type is a
* Collection but its element type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Collection} or array type
*/
@Nullable
public TypeDescriptor getElementTypeDescriptor() {
if (getResolvableType().isArray()) {
return new TypeDescriptor(getResolvableType().getComponentType(), null, getAnnotations());
}
if (Stream.class.isAssignableFrom(getType())) {
return getRelatedIfResolvable(this, getResolvableType().as(Stream.class).getGeneric(0));
}
return getRelatedIfResolvable(this, getResolvableType().asCollection().getGeneric(0));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* If this type is an array, returns the array's component type.
* If this type is a {@code Stream}, returns the stream's component type.
* If this type is a {@link Collection} and it is parameterized, returns the Collection's element type.
* If the Collection is not parameterized, returns {@code null} indicating the element type is not declared.
* @return the array component type or Collection element type, or {@code null} if this type is a
* Collection but its element type is not parameterized
* @throws IllegalStateException if this type is not a {@code java.util.Collection} or array type
*/
@Nullable
public TypeDescriptor getElementTypeDescriptor() {
if (getResolvableType().isArray()) {
return new TypeDescriptor(getResolvableType().getComponentType(), null, getAnnotations());
}
if (Stream.class.isAssignableFrom(getType())) {
return getRelatedIfResolvable(this, getResolvableType().as(Stream.class).getGeneric(0));
}
return getRelatedIfResolvable(this, getResolvableType().asCollection().getGeneric(0));
}
内容来源于网络,如有侵权,请联系作者删除!