本文整理了Java中java.lang.Class.isArray()
方法的一些代码示例,展示了Class.isArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Class.isArray()
方法的具体详情如下:
包路径:java.lang.Class
类名称:Class
方法名:isArray
[英]Tests whether the class represented by this Class is an array class.
[中]测试此类表示的类是否为数组类。
代码示例来源:origin: apache/incubator-dubbo
@Override
public boolean accept(Type type, Class<?> clazz) {
if (clazz == null) {
return false;
}
return clazz.isArray();
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public boolean accept(Type type, Class<?> clazz) {
if (clazz == null) {
return false;
}
return clazz.isArray();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Returns '{@code true}' for arrays, {@link Collection Collections}
* and {@link Map Maps}.
*/
private static boolean typeRequiresMultiple(Class<?> type) {
return (type.isArray() || Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the given object is an array:
* either an Object array or a primitive array.
* @param obj the object to check
*/
public static boolean isArray(@Nullable Object obj) {
return (obj != null && obj.getClass().isArray());
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Determine if the object needs wrap
*
* @param clazz object type
* @return need wrap
*/
public static boolean needWrapper(Class<?> clazz) {
return WrapperUtils.WRAPPER_SET.contains(clazz) || clazz.isArray() || clazz.isEnum();
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Determine if the object needs wrap
*
* @param clazz object type
* @return need wrap
*/
public static boolean needWrapper(Class<?> clazz) {
return WrapperUtils.WRAPPER_SET.contains(clazz) || clazz.isArray() || clazz.isEnum();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Check if the given class represents an array of primitives,
* i.e. boolean, byte, char, short, int, long, float, or double.
* @param clazz the class to check
* @return whether the given class is a primitive array class
*/
public static boolean isPrimitiveArray(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isArray() && clazz.getComponentType().isPrimitive());
}
代码示例来源:origin: google/guava
@Override
Type usedInGenericType(Type type) {
checkNotNull(type);
if (type instanceof Class) {
Class<?> cls = (Class<?>) type;
if (cls.isArray()) {
return new GenericArrayTypeImpl(cls.getComponentType());
}
}
return type;
}
},
代码示例来源:origin: spring-projects/spring-framework
/**
* Is this type an array type?
*/
public boolean isArray() {
return getType().isArray();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void printValue(String label, @Nullable Object value) {
if (value != null && value.getClass().isArray()) {
value = CollectionUtils.arrayToList(value);
}
writer.println(String.format("%17s = %s", label, value));
}
});
代码示例来源:origin: spring-projects/spring-framework
private void appendType(StringBuilder sb, Class<?> type, boolean useLongTypeName) {
if (type.isArray()) {
appendType(sb, type.getComponentType(), useLongTypeName);
sb.append("[]");
}
else {
sb.append(useLongTypeName ? type.getName() : type.getSimpleName());
}
}
}
代码示例来源:origin: spring-projects/spring-framework
private boolean isBindingCandidate(String name, @Nullable Object value) {
return (!name.startsWith(BindingResult.MODEL_KEY_PREFIX) && value != null &&
!value.getClass().isArray() && !(value instanceof Collection) &&
!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Check if the given class represents an array of primitive wrappers,
* i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double.
* @param clazz the class to check
* @return whether the given class is a primitive wrapper array class
*/
public static boolean isPrimitiveWrapperArray(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isArray() && isPrimitiveWrapper(clazz.getComponentType()));
}
代码示例来源:origin: apache/incubator-dubbo
private static boolean isPrimitives(Class<?> cls) {
if (cls.isArray()) {
return isPrimitive(cls.getComponentType());
}
return isPrimitive(cls);
}
代码示例来源:origin: apache/incubator-dubbo
public static boolean isPrimitives(Class<?> cls) {
if (cls.isArray()) {
return isPrimitive(cls.getComponentType());
}
return isPrimitive(cls);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return {@code true} if this type resolves to a Class that represents an array.
* @see #getComponentType()
*/
public boolean isArray() {
if (this == NONE) {
return false;
}
return ((this.type instanceof Class && ((Class<?>) this.type).isArray()) ||
this.type instanceof GenericArrayType || resolveType().isArray());
}
代码示例来源:origin: apache/incubator-dubbo
@Override
protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException {
Class<?> clazz = desc.forClass();
if (clazz.isPrimitive() || clazz.isArray()) {
write(0);
super.writeClassDescriptor(desc);
} else {
write(1);
writeUTF(desc.getName());
}
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException {
Class<?> clazz = desc.forClass();
if (clazz.isPrimitive() || clazz.isArray()) {
write(0);
super.writeClassDescriptor(desc);
} else {
write(1);
writeUTF(desc.getName());
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testBeanPropertyIsArray() {
PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(ContainerBean.class);
for (PropertyDescriptor descriptor : descriptors) {
if ("containedBeans".equals(descriptor.getName())) {
assertTrue("Property should be an array", descriptor.getPropertyType().isArray());
assertEquals(descriptor.getPropertyType().getComponentType(), ContainedBean.class);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void arrayClassType() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("arrayClassType"));
assertThat(type.getType(), instanceOf(Class.class));
assertThat(((Class) type.getType()).isArray(), equalTo(true));
}
内容来源于网络,如有侵权,请联系作者删除!