- List<Method> methods = ReflectionUtils.getAllMethods(aClass,
- Object.class);
- for (Method method : methods) {
- if (method.isAnnotationPresent(aAnnotation)) {
- String setterName = null;
- if (method.getName().startsWith("get")) {
- setterName = method.getName().replaceFirst("get", "set");
- } else if (method.getName().startsWith("is")) {
- setterName = method.getName().replaceFirst("is", "set");
- }
- try {
- Class returnType = method.getReturnType();
- Method setter = method.getDeclaringClass()
- .getDeclaredMethod(setterName, returnType);
- return new PropertyAccessor(method, setter);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("Error obtaining setter for " +
- method.getName() + " in class " + aClass.getName(), e);
- }
- }
+ if (pk != null|| version != null) {
+ return new EntityAccessor(pk, version);