public static boolean isTypeOf(Object val, Class...ts) { return isTypeOf(val.getClass(), ts); }
public static <T> T stringToValue(String str, Class<T> clazz) { if (str == null && isTypeOf(clazz, Integer.class, Long.class, Float.class, Double.class, String.class)) { return null; } return toValue(str, clazz); }
public static boolean isPrimitiveTypeForKeyValue(Class type) { if (TypeUtils.isPrimitiveOrWrapper(type)) { return true; } if (TypeUtils.isTypeOf(type, Date.class, Timestamp.class)) { return true; } return false; } }
public static boolean isZstackBeanPrimitive(Class clazz) { return isPrimitiveOrWrapper(clazz) || isTypeOf(clazz, Timestamp.class); }
private String validate(Object obj, Field f) { try { f.setAccessible(true); Object value = f.get(obj); Validation at = f.getAnnotation(Validation.class); if (at.notNull() && value == null) { return error(obj, f, "field can not be null"); } if (at.notZero() && TypeUtils.isTypeOf(value, Integer.TYPE, Integer.class, Long.TYPE, Long.class)) { if (value != null) { long intValue = Long.valueOf(value.toString()); if (intValue == 0) { return error(obj, f, "field can not be zero"); } } } return null; } catch (Exception e) { throw new CloudRuntimeException(e); } }
if (value != null && param.numberRange().length > 0 && TypeUtils.isTypeOf(value, Integer.TYPE, Integer.class, Long.TYPE, Long.class)) { DebugUtils.Assert(param.numberRange().length == 2, String.format("invalid field[%s], Param.numberRange must have and only have 2 items.", f.getName())); long low = param.numberRange()[0];
if (TypeUtils.isTypeOf(clazz, APISearchMessage.class, APIGetMessage.class, APIListMessage.class)) { continue;
continue; if (TypeUtils.isTypeOf(clazz, APISearchMessage.class, APIListMessage.class, APIGetMessage.class)) { continue;
if (TypeUtils.isTypeOf(clazz, APISearchMessage.class, APIGetMessage.class, APIListMessage.class)) { continue;
if (value != null && at.numberRange().length > 0 && TypeUtils.isTypeOf(value, Integer.TYPE, Integer.class, Long.TYPE, Long.class)) { DebugUtils.Assert(at.numberRange().length == 2, String.format("invalid field[%s], APIParam.numberRange must have and only have 2 items", f.getName())); long low = at.numberRange()[0];
return call(); } catch (Throwable t) { if (onExceptions.length != 0 && !TypeUtils.isTypeOf(t, onExceptions)) { throw t;