/** * Returns true if this type is one of the nine primitive types (including {@code void}). * * @since 15.0 */ public final boolean isPrimitive() { return (runtimeType instanceof Class) && ((Class<?>) runtimeType).isPrimitive(); }
private static boolean isPrimitive(Class<?> cls) { return cls.isPrimitive() || cls == Boolean.class || cls == Byte.class || cls == Character.class || cls == Short.class || cls == Integer.class || cls == Long.class || cls == Float.class || cls == Double.class || cls == String.class || cls == Date.class || cls == Class.class; }
private static boolean isPrimitive(Class<?> cls) { return cls.isPrimitive() || cls == Boolean.class || cls == Byte.class || cls == Character.class || cls == Short.class || cls == Integer.class || cls == Long.class || cls == Float.class || cls == Double.class || cls == String.class || cls == Date.class || cls == Class.class; }
public static boolean isPrimitive(Class<?> type) { return type.isPrimitive() || type == String.class || type == Character.class || type == Boolean.class || type == Byte.class || type == Short.class || type == Integer.class || type == Long.class || type == Float.class || type == Double.class || type == Object.class; }
public static boolean isPrimitive(Class<?> type) { return type.isPrimitive() || type == String.class || type == Character.class || type == Boolean.class || type == Byte.class || type == Short.class || type == Integer.class || type == Long.class || type == Float.class || type == Double.class || type == Object.class; }
static void checkNotPrimitive(Type type) { if (type instanceof Class<?> && ((Class<?>) type).isPrimitive()) { throw new IllegalArgumentException(); } }
private static void disallowPrimitiveType(Type[] types, String usedAs) { for (Type type : types) { if (type instanceof Class) { Class<?> cls = (Class<?>) type; checkArgument(!cls.isPrimitive(), "Primitive type '%s' used as %s", cls, usedAs); } } }
/** * Resolve the given class if it is a primitive class, * returning the corresponding primitive wrapper type instead. * @param clazz the class to check * @return the original class, or a primitive wrapper for the original primitive type */ public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) { Assert.notNull(clazz, "Class must not be null"); return (clazz.isPrimitive() && clazz != void.class ? primitiveTypeToWrapperMap.get(clazz) : clazz); }
private static boolean isPrimitive(Class<?> cls) { return cls.isPrimitive() || cls == String.class || cls == Boolean.class || cls == Character.class || Number.class.isAssignableFrom(cls) || Date.class.isAssignableFrom(cls); }
public static boolean isPrimitive(Class<?> cls) { return cls.isPrimitive() || cls == String.class || cls == Boolean.class || cls == Character.class || Number.class.isAssignableFrom(cls) || Date.class.isAssignableFrom(cls); }
private static boolean isPrimitive(Class<?> cls) { return cls.isPrimitive() || cls == String.class || cls == Boolean.class || cls == Character.class || Number.class.isAssignableFrom(cls) || Date.class.isAssignableFrom(cls); }
public static boolean isPrimitive(Class<?> cls) { return cls.isPrimitive() || cls == String.class || cls == Boolean.class || cls == Character.class || Number.class.isAssignableFrom(cls) || Date.class.isAssignableFrom(cls); }
/** * 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()); }
/** * Is this type a primitive type? */ public boolean isPrimitive() { return getType().isPrimitive(); }
private int countNumberOfUnboundPrimitiveArguments() { int count = 0; for (int i = 0; i < this.argumentTypes.length; i++) { if (isUnbound(i) && this.argumentTypes[i].isPrimitive()) { count++; } } return count; }
/** * Check if the given class represents a primitive (i.e. boolean, byte, * char, short, int, long, float, or double) or a primitive wrapper * (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 or primitive wrapper class */ public static boolean isPrimitiveOrWrapper(Class<?> clazz) { Assert.notNull(clazz, "Class must not be null"); return (clazz.isPrimitive() || isPrimitiveWrapper(clazz)); }
/** * Determine if the given type is assignable from the given value, * assuming setting by reflection. Considers primitive wrapper classes * as assignable to the corresponding primitive types. * @param type the target type * @param value the value that should be assigned to the type * @return if the type is assignable from the value */ public static boolean isAssignableValue(Class<?> type, @Nullable Object value) { Assert.notNull(type, "Type must not be null"); return (value != null ? isAssignable(type, value.getClass()) : !type.isPrimitive()); }
static boolean isPrimitiveOrNullable(Parameter param) { return param.getType().getRawType().isPrimitive() || isNullable(param); }
@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()); } } }
@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()); } } }