public static Set<Method> getAllMethods(Set<Method> methods, Class<?> type) { return getAllMethods(methods, type, 0); }
public static Set<Field> getAllFields(Set<Field> fields, Class<?> type) { return getAllFields(fields, type, 0); }
private static boolean assignParam(Class<?> expectedClass, Object[] p, int i, Object param) { Class<?> paramClass = param.getClass(); if (!ReflectionUtil.isNumeric(expectedClass)) { return false; } else {
return; Set<Field> fields = ReflectionUtil.getAllFields(new HashSet<Field>(), instance.getClass()); for (Field field : fields) { try { Object param; if (local.has(fieldType) && (param = local.get(fieldType)) != null) { if (setField(instance, field, param)) { continue; if (provider.has(fieldType) && (param = provider.get(fieldType)) != null) { if (setField(instance, field, param)) { break;
return; Set<Field> fields = ReflectionUtil.getAllFields(new HashSet<Field>(), instance.getClass()); for (Field field : fields) { try { Object param; if (local.has(fieldType) && (param = local.get(fieldType)) != null) { if (setField(instance, field, param)) { continue; if (provider.has(fieldType) && (param = provider.get(fieldType)) != null) { if (setField(instance, field, param)) { break;
public static Set<Field> getAllFields(Set<Field> fields, Class<?> type) { return getAllFields(fields, type, 0); }
private static boolean assignParam(Class<?> expectedClass, Object[] p, int i, Object param) { Class<?> paramClass = param.getClass(); if (!ReflectionUtil.isNumeric(expectedClass)) { return false; } else {
public static Set<Method> getAllMethods(Set<Method> methods, Class<?> type) { return getAllMethods(methods, type, 0); }
public static Set<Field> getAllFields(Set<Field> fields, Class<?> type, int depth) { //first get inherited fields if (type.getSuperclass() != null && depth <= MAX_RECURSION_DEPTH) { getAllFields(fields, type.getSuperclass(), ++depth); } //now add all "local" fields Collections.addAll(fields, type.getDeclaredFields()); return fields; }
protected Object extractHeaderParam(MethodParam param, HttpRequest request) { //header param can be a list or string, if neither set to null if (List.class.isAssignableFrom(param.getParameterType())) { return request.headers().getAll(param.getName()); } else { if (String.class.isAssignableFrom(param.getParameterType())) { return request.headers().get(param.getName()); } else { if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, request.headers().get(param.getName())); } else { return null; } } } }
public static Method[] getAllMethods(Class<?> klass) { HashSet<Method> methods = new HashSet<>(); getAllMethods(methods, klass); return methods.toArray(new Method[methods.size()]); }
public static Set<Field> getAllFields(Set<Field> fields, Class<?> type, int depth) { //first get inherited fields if (type.getSuperclass() != null && depth <= MAX_RECURSION_DEPTH) { getAllFields(fields, type.getSuperclass(), ++depth); } //now add all "local" fields Collections.addAll(fields, type.getDeclaredFields()); return fields; }
protected Object extractCookieParam(MethodParam param, HttpRequest request) { HttpCookie cookie = request.getCookie(param.getName()); if (cookie == null) { return null; } if (String.class.isAssignableFrom(param.getParameterType())) { return cookie.getValue(); } else if (HttpCookie.class.isAssignableFrom(param.getParameterType())) { return cookie; } else if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, cookie.getValue()); } else { return null; } }
public static Method[] getAllMethods(Class<?> klass) { HashSet<Method> methods = new HashSet<>(); getAllMethods(methods, klass); return methods.toArray(new Method[methods.size()]); }
public HttpCookie(Cookie cookie) { this(cookie.getName(), cookie.getValue()); Set<Field> fields = ReflectionUtil.getAllFields(new HashSet<Field>(), DefaultCookie.class, 1); for (Field field : fields) { try { if (!Modifier.isFinal(field.getModifiers())) { field.setAccessible(true); field.set(this, field.get(cookie)); } } catch (Throwable t) { log.warn("Error copying cookie field", t); } } }
protected Object extractPathParam(MethodParam param, ResourcePath path) { ResourcePath.Component component = path.getComponent(param.getName()); if (String.class.isAssignableFrom(param.getParameterType())) { if (component != null) { return component.getRuntimeValue(); } } else { if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, component == null ? null : component.getRuntimeValue()); } } return null; }
public static Set<Method> getAllMethods(Set<Method> methods, Class<?> type, int depth) { if (type.getSuperclass() != null && depth <= MAX_RECURSION_DEPTH) { getAllMethods(methods, type.getSuperclass(), ++depth); } Collections.addAll(methods, type.getDeclaredMethods()); return methods; }
protected Object extractFormParam(MethodParam param, HttpRequest request) { Object obj = request.getFormParam().get(param.getName()); if (obj != null && param.getParameterType().isAssignableFrom(obj.getClass())) { return obj; } else { if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, (String) request.getFormParam().get(param.getName())); } else { return null; } } }
public static Set<Method> getAllMethods(Set<Method> methods, Class<?> type, int depth) { if (type.getSuperclass() != null && depth <= MAX_RECURSION_DEPTH) { getAllMethods(methods, type.getSuperclass(), ++depth); } Collections.addAll(methods, type.getDeclaredMethods()); return methods; }
protected Object extractQueryParam(MethodParam param, HttpRequest request) { //query string param can be a list or string, if neither set to null if (List.class.isAssignableFrom(param.getParameterType())) { return request.getQueryParams().get(param.getName()); } else if (String.class.isAssignableFrom(param.getParameterType())) { return request.getQueryParams().getFirst(param.getName()); } else { if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, request.getQueryParams().getFirst(param.getName())); } else { return null; } } }