/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = new HashMap<>(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
@Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } }));
@Override public Result process(final EntityProcessorContext context) { switch (context.getType()) { case CLASS_READER: case CLASS_WRITER: final EntityGraph graph = context.getEntityGraph(); if (graph.getFilteringScopes().isEmpty()) { graph.addFilteringScopes(FilteringHelper.getDefaultFilteringScope()); } return Result.APPLY; case PROPERTY_READER: case PROPERTY_WRITER: final Field field = context.getField(); process(context.getEntityGraph(), field.getName(), field.getGenericType()); return Result.APPLY; case METHOD_READER: case METHOD_WRITER: final Method method = context.getMethod(); process(context.getEntityGraph(), ReflectionHelper.getPropertyName(method), method.getGenericReturnType()); return Result.APPLY; default: // NOOP. } return Result.SKIP; }
fieldType = field.getGenericType(); } else { fieldName = ReflectionHelper.getPropertyName(method); fieldType = ReflectionHelper.isGetter(method) ? method.getGenericReturnType() : method .getGenericParameterTypes()[0];
@Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } }));
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = new HashMap<>(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = Maps.newHashMap(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = Maps.newHashMap(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
@Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } }));
@Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } }));
@Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } }));
@Override public Result process(final EntityProcessorContext context) { switch (context.getType()) { case CLASS_READER: case CLASS_WRITER: final EntityGraph graph = context.getEntityGraph(); if (graph.getFilteringScopes().isEmpty()) { graph.addFilteringScopes(FilteringHelper.getDefaultFilteringScope()); } return Result.APPLY; case PROPERTY_READER: case PROPERTY_WRITER: final Field field = context.getField(); process(context.getEntityGraph(), field.getName(), field.getGenericType()); return Result.APPLY; case METHOD_READER: case METHOD_WRITER: final Method method = context.getMethod(); process(context.getEntityGraph(), ReflectionHelper.getPropertyName(method), method.getGenericReturnType()); return Result.APPLY; default: // NOOP. } return Result.SKIP; }
fieldType = field.getGenericType(); } else { fieldName = ReflectionHelper.getPropertyName(method); fieldType = ReflectionHelper.isGetter(method) ? method.getGenericReturnType() : method .getGenericParameterTypes()[0];
fieldType = field.getGenericType(); } else { fieldName = ReflectionHelper.getPropertyName(method); fieldType = ReflectionHelper.isGetter(method) ? method.getGenericReturnType() : method .getGenericParameterTypes()[0];
@Override public Result process(final EntityProcessorContext context) { switch (context.getType()) { case CLASS_READER: case CLASS_WRITER: final EntityGraph graph = context.getEntityGraph(); if (graph.getFilteringScopes().isEmpty()) { graph.addFilteringScopes(FilteringHelper.getDefaultFilteringScope()); } return Result.APPLY; case PROPERTY_READER: case PROPERTY_WRITER: final Field field = context.getField(); process(context.getEntityGraph(), field.getName(), field.getGenericType()); return Result.APPLY; case METHOD_READER: case METHOD_WRITER: final Method method = context.getMethod(); process(context.getEntityGraph(), ReflectionHelper.getPropertyName(method), method.getGenericReturnType()); return Result.APPLY; default: // NOOP. } return Result.SKIP; }
@Override public Result process(final EntityProcessorContext context) { switch (context.getType()) { case CLASS_READER: case CLASS_WRITER: final EntityGraph graph = context.getEntityGraph(); if (graph.getFilteringScopes().isEmpty()) { graph.addFilteringScopes(FilteringHelper.getDefaultFilteringScope()); } return Result.APPLY; case PROPERTY_READER: case PROPERTY_WRITER: final Field field = context.getField(); process(context.getEntityGraph(), field.getName(), field.getGenericType()); return Result.APPLY; case METHOD_READER: case METHOD_WRITER: final Method method = context.getMethod(); process(context.getEntityGraph(), ReflectionHelper.getPropertyName(method), method.getGenericReturnType()); return Result.APPLY; default: // NOOP. } return Result.SKIP; }
fieldType = field.getGenericType(); } else { fieldName = ReflectionHelper.getPropertyName(method); fieldType = ReflectionHelper.isGetter(method) ? method.getGenericReturnType() : method .getGenericParameterTypes()[0];