public static boolean isSimple(Object target) { return kindOf(target).isConcrete(); }
private static IReqInfo createInfo() { if (Cls.exists(RAPIDOID_CTX)) { return (IReqInfo) Cls.newInstance(Cls.get("org.rapidoid.http.impl.RapidoidReqInfo")); } return NO_REQ_INFO; }
public static void watchForChanges(String path, Operation<String> changeListener) { Class<?> watch = Cls.getClassIfExists("org.rapidoid.io.watch.Watch"); if (watch != null) { Method dir = Cls.getMethod(watch, "dir", String.class, Operation.class); Cls.invokeStatic(dir, path, changeListener); } }
public static Object[] instantiateAll(Class<?>... classes) { Object[] instances = new Object[classes.length]; for (int i = 0; i < instances.length; i++) { instances[i] = newInstance(classes[i]); } return instances; }
public MapProp(String name, Object key, Class<?> type) { this.name = name; this.key = key; this.type = type; this.typeKind = Cls.kindOf(type); }
public static Object invokeStatic(String className, String methodName, Object... args) { Class<?> cls = Cls.get(className); Method method = findMethodByArgs(cls, methodName, args); return invokeStatic(method, args); }
public static boolean areAssignable(Class<?>[] types, Object[] values) { if (types.length != values.length) { return false; } for (int i = 0; i < values.length; i++) { Object val = values[i]; if (val != null && !instanceOf(val, types[i])) { return false; } } return true; }
@SuppressWarnings("unchecked") @Override public <T> T getRaw(Object target) { return (T) Cls.invokeStatic("org.rapidoid.gui.GUIActions", "of", target); }
protected static byte code(TypeKind kind) { int ordinal = kind.ordinal(); assert ordinal < 128; return (byte) ordinal; }
private static boolean isBean(Object obj) { return Cls.isBean(obj) && !(obj instanceof Tag) && !(obj instanceof TagWidget); }
@SuppressWarnings("unchecked") public static <T> T getFieldValue(Object instance, String fieldName, T defaultValue) { try { return (T) getFieldValue(instance, fieldName); } catch (Exception e) { return defaultValue; } }
public static Object[] getAssignableArgs(Class<?>[] types, Collection<?> properties) { Object[] args = new Object[types.length]; for (int i = 0; i < types.length; i++) { Class<?> type = types[i]; args[i] = getUniqueInstanceOf(type, properties); } return args; }
@Override public Short shortObj(T context) { return shortValue(context); }
@Override public Double doubleObj(T context) { return doubleValue(context); }
@Override public Float floatObj(T context) { return floatValue(context); }
@Override public Boolean booleanObj(T context) { return booleanValue(context); }
@Override public Byte byteObj(T context) { return byteValue(context); }