public static Set<Field> getAllFields(Set<Field> fields, Class<?> type) { return getAllFields(fields, type, 0); }
public static Set<Method> getAllMethods(Set<Method> methods, Class<?> type) { return getAllMethods(methods, type, 0); }
(response != null && !ReflectionUtil.isNumeric(response.getClass()) && !(response instanceof Collection))) { Set<Field> fields = ReflectionUtil.getAllFields(new HashSet<Field>(), response.getClass(), 10); Map<String, Object> variables = new HashMap<>(); scopes.add(variables);
private static boolean assignParam(Class<?> expectedClass, Object[] p, int i, Object param) { Class<?> paramClass = param.getClass(); if (!ReflectionUtil.isNumeric(expectedClass)) { return false; } else {
(response != null && !ReflectionUtil.isNumeric(response.getClass()) && !(response instanceof Collection))) { Set<Field> fields = ReflectionUtil.getAllFields(new HashSet<Field>(), response.getClass(), 10); for (Field field : fields) { try {
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<Field> getAllFields(Set<Field> fields, Class<?> type) { return getAllFields(fields, type, 0); }
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; }
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 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 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 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 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; }
Set<Field> fields = ReflectionUtil.getAllFields(new HashSet<Field>(), klass, 0); for (Field field : fields) {
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; }