/** * Creates property descriptor. */ public PropertyDescriptor(ClassDescriptor classDescriptor, String propertyName, MethodDescriptor readMethod, MethodDescriptor writeMethod) { super(classDescriptor, ((readMethod == null) || readMethod.isPublic()) & (writeMethod == null || writeMethod.isPublic()) ); this.name = propertyName; this.readMethodDescriptor = readMethod; this.writeMethodDescriptor = writeMethod; if (classDescriptor.isExtendedProperties()) { String[] prefix = classDescriptor.getPropertyFieldPrefix(); FieldDescriptor fd = null; if (prefix != null) { for (String p : prefix) { fd = findField(p + propertyName); if (fd != null) { break; } } } else { fd = findField(propertyName); } this.fieldDescriptor = fd; } else { this.fieldDescriptor = null; } }
public Class getGetterRawComponentType() { return getRawReturnComponentType(); }
/** * Returns property type. Raw types are detected. */ public Class getType() { if (type == null) { if (fieldDescriptor != null) { type = fieldDescriptor.getRawType(); } else if (readMethodDescriptor != null) { type = readMethodDescriptor.getGetterRawType(); } else if (writeMethodDescriptor != null) { type = writeMethodDescriptor.getSetterRawType(); } } return type; }
int mc = 0; for (MethodDescriptor md : mds) { if (md.isPublic()) mc++; Method m2 = cd.getMethodDescriptor("m", params, true).getMethod(); assertNotNull(m2); assertEquals(m, m2); assertEquals(m, md1.getMethod()); assertArrayEquals(params, getRawParameterTypes(md1)); assertEquals(void.class, md1.getRawReturnType()); assertNull(md1.getRawReturnComponentType()); assertEquals(List.class, md2.getRawReturnType()); assertEquals(List.class, md2.getRawReturnComponentType()); assertEquals(List.class, md3.getRawReturnType()); assertEquals(Object.class, md3.getRawReturnComponentType()); assertEquals(List.class, md4.getRawReturnType()); assertEquals(Byte.class, md4.getRawReturnComponentType()); assertEquals(List.class, md4.getSetterRawType()); assertEquals(Long.class, md4.getSetterRawComponentType()); assertEquals(List.class, md5.getRawReturnType()); assertEquals(Object.class, md5.getRawReturnComponentType()); assertEquals(List.class, md5.getSetterRawType()); assertEquals(Object.class, md5.getSetterRawComponentType());
/** * Builds action runtime configuration on founded action class. * Action classes are annotated with {@link jodd.madvoc.meta.MadvocAction} annotation. */ @SuppressWarnings("NonConstantStringShouldBeStringBuffer") protected void acceptActionClass(final Class<?> actionClass) { if (actionClass == null) { return; } if (!checkClass(actionClass)) { return; } if (actionClass.getAnnotation(MadvocAction.class) == null) { return; } ClassDescriptor cd = ClassIntrospector.get().lookup(actionClass); MethodDescriptor[] allMethodDescriptors = cd.getAllMethodDescriptors(); for (MethodDescriptor methodDescriptor : allMethodDescriptors) { if (!methodDescriptor.isPublic()) { continue; } // just public methods final Method method = methodDescriptor.getMethod(); final boolean hasAnnotation = actionConfigManager.hasActionAnnotationOn(method); if (!hasAnnotation) { continue; } webappConfigurations.add(() -> actionsManager.registerAction(actionClass, method, null)); } }
/** * Creates a {@link Getter}. */ protected Getter createGetter(boolean declared) { if (readMethodDescriptor != null) { if (readMethodDescriptor.matchDeclared(declared)) { return readMethodDescriptor; } } if (fieldDescriptor != null) { if (fieldDescriptor.matchDeclared(declared)) { return fieldDescriptor; } } return null; }
public Class getGetterRawType() { return getRawReturnType(); }
/** * Creates new {@code MethodDescriptor}. */ protected MethodDescriptor createMethodDescriptor(Method method) { return new MethodDescriptor(classDescriptor, method); }
assertEquals("isFlag", propertyDescriptors[0].getReadMethodDescriptor().getMethod().getName()); MethodDescriptor[] mds = cd.getAllMethodDescriptors(); int c = 0; for (MethodDescriptor md : mds) { if (md.isPublic()) c++; assertEquals("isFlag", propertyDescriptors[0].getReadMethodDescriptor().getMethod().getName()); mds = cd.getAllMethodDescriptors(); c = 0; for (MethodDescriptor md : mds) { if (md.isPublic()) c++;
/** * Creates a {@link Setter}. */ protected Setter createSetter(boolean declared) { if (writeMethodDescriptor != null) { if (writeMethodDescriptor.matchDeclared(declared)) { return writeMethodDescriptor; } } if (fieldDescriptor != null) { if (fieldDescriptor.matchDeclared(declared)) { return fieldDescriptor; } } return null; }
/** * Returns property type. Raw types are detected. */ public Class getType() { if (type == null) { if (fieldDescriptor != null) { type = fieldDescriptor.getRawType(); } else if (readMethodDescriptor != null) { type = readMethodDescriptor.getGetterRawType(); } else if (writeMethodDescriptor != null) { type = writeMethodDescriptor.getSetterRawType(); } } return type; }
@Override public Class getGetterRawType() { return getRawReturnType(); }
/** * Creates new {@code MethodDescriptor}. */ protected MethodDescriptor createMethodDescriptor(final Method method) { return new MethodDescriptor(classDescriptor, method); }
/** * Creates a {@link Setter}. */ protected Setter createSetter(final boolean declared) { if (writeMethodDescriptor != null) { if (writeMethodDescriptor.matchDeclared(declared)) { return writeMethodDescriptor; } } if (fieldDescriptor != null) { if (fieldDescriptor.matchDeclared(declared)) { return fieldDescriptor; } } return null; }
/** * Returns property type. Raw types are detected. */ public Class getType() { if (type == null) { if (fieldDescriptor != null) { type = fieldDescriptor.getRawType(); } else if (readMethodDescriptor != null) { type = readMethodDescriptor.getGetterRawType(); } else if (writeMethodDescriptor != null) { type = writeMethodDescriptor.getSetterRawType(); } } return type; }
/** * Creates property descriptor. */ public PropertyDescriptor(final ClassDescriptor classDescriptor, final String propertyName, final MethodDescriptor readMethod, final MethodDescriptor writeMethod) { super(classDescriptor, ((readMethod == null) || readMethod.isPublic()) & (writeMethod == null || writeMethod.isPublic()) ); this.name = propertyName; this.readMethodDescriptor = readMethod; this.writeMethodDescriptor = writeMethod; if (classDescriptor.isExtendedProperties()) { String[] prefix = classDescriptor.getPropertyFieldPrefix(); FieldDescriptor fd = null; if (prefix != null) { for (String p : prefix) { fd = findField(p + propertyName); if (fd != null) { break; } } } else { fd = findField(propertyName); } this.fieldDescriptor = fd; } else { this.fieldDescriptor = null; } }
@Override public Class getGetterRawComponentType() { return getRawReturnComponentType(); }
@Override public Class getGetterRawType() { return getRawReturnType(); }