/** * 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; } }
/** * 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; } }
/** * 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)); } }
@Test void testPropertyMatches() { ClassDescriptor cd = ClassIntrospector.get().lookup(Cbean.class); PropertyDescriptor pd; pd = cd.getPropertyDescriptor("s1", false); assertNull(pd); pd = cd.getPropertyDescriptor("s1", true); assertFalse(pd.isPublic()); assertTrue(pd.getReadMethodDescriptor().isPublic()); assertFalse(pd.getWriteMethodDescriptor().isPublic()); assertNotNull(getPropertyGetterDescriptor(cd, "s1", false)); assertNull(getPropertySetterDescriptor(cd, "s1", false)); pd = cd.getPropertyDescriptor("s2", false); assertNull(pd); pd = cd.getPropertyDescriptor("s2", true); assertFalse(pd.isPublic()); assertFalse(pd.getReadMethodDescriptor().isPublic()); assertTrue(pd.getWriteMethodDescriptor().isPublic()); assertNull(getPropertyGetterDescriptor(cd, "s2", false)); assertNotNull(getPropertySetterDescriptor(cd, "s2", false)); pd = cd.getPropertyDescriptor("s3", false); assertNotNull(pd); pd = cd.getPropertyDescriptor("s3", true); assertTrue(pd.isPublic()); assertTrue(pd.getReadMethodDescriptor().isPublic()); assertTrue(pd.getWriteMethodDescriptor().isPublic()); assertNotNull(getPropertyGetterDescriptor(cd, "s3", false)); assertNotNull(getPropertySetterDescriptor(cd, "s3", false)); }
int mc = 0; for (MethodDescriptor md : mds) { if (md.isPublic()) mc++;
/** * 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; } }