private void validateProperty(final MetaClass bindable, final String property) { if (!bindable.getBeanDescriptor().getProperties().contains(property)) { throw new RuntimeException(String.format("Invalid property name [%s] in @Bindable type [%s].", property, bindable.getFullyQualifiedName())); } }
private void validateProperty(final MetaClass bindable, final String property) { if (!bindable.getBeanDescriptor().getProperties().contains(property)) { throw new RuntimeException(String.format("Invalid property name [%s] in @Bindable type [%s].", property, bindable.getFullyQualifiedName())); } }
/** * @param bindableType * The root type the given property chain is resolved against. Not null. * @param propertyChain * The data binding property chain to validate. Not null. * @return The type of the given property within the given bindable type. */ public static MetaClass getPropertyType(final MetaClass bindableType, final String propertyChain) { if ("this".equals(propertyChain)) { return bindableType; } final int dotPos = propertyChain.indexOf('.'); if (dotPos >= 0) { final String firstProp = propertyChain.substring(0, dotPos); final String subChain = propertyChain.substring(dotPos+1); return getPropertyType(bindableType.getBeanDescriptor().getPropertyType(firstProp), subChain); } else { return bindableType.getBeanDescriptor().getPropertyType(propertyChain); } } }
/** * @param bindableType * The root type the given property chain is resolved against. Not null. * @param propertyChain * The data binding property chain to validate. Not null. * @return The type of the given property within the given bindable type. */ public static MetaClass getPropertyType(final MetaClass bindableType, final String propertyChain) { if ("this".equals(propertyChain)) { return bindableType; } final int dotPos = propertyChain.indexOf('.'); if (dotPos >= 0) { final String firstProp = propertyChain.substring(0, dotPos); final String subChain = propertyChain.substring(dotPos+1); return getPropertyType(bindableType.getBeanDescriptor().getPropertyType(firstProp), subChain); } else { return bindableType.getBeanDescriptor().getPropertyType(propertyChain); } } }
return bindableType.getBeanDescriptor().getProperties().contains(propertyChain); if (!bindableType.getBeanDescriptor().getProperties().contains(thisProperty)) { return false; MetaClass propertyType = bindableType.getBeanDescriptor().getPropertyType(thisProperty); return isValidPropertyChain(propertyType, moreProperties);
return bindableType.getBeanDescriptor().getProperties().contains(propertyChain); if (!bindableType.getBeanDescriptor().getProperties().contains(thisProperty)) { return false; MetaClass propertyType = bindableType.getBeanDescriptor().getPropertyType(thisProperty); return isValidPropertyChain(propertyType, moreProperties);
/** * Generates a getter method for the provided property plus the corresponding code for the * implementation of {@link HasProperties#get(String)}. */ private void generateGetter(final ClassStructureBuilder<?> classBuilder, final String property, final CaseBlockBuilder switchBlock) { final MetaMethod getterMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); if (getterMethod != null && !getterMethod.isFinal() && getterMethod.isPublic()) { BlockBuilder<CaseBlockBuilder> caseBlock = switchBlock.case_(property); caseBlock.append(Stmt.loadVariable("this").invoke(getterMethod.getName()).returnValue()).finish(); classBuilder.publicMethod(getterMethod.getReturnType(), getterMethod.getName()) .append(target().invoke(getterMethod.getName()).returnValue()) .finish(); proxiedAccessorMethods.add(getterMethod); } }
/** * Generates a getter method for the provided property plus the corresponding code for the * implementation of {@link HasProperties#get(String)}. */ private void generateGetter(final ClassStructureBuilder<?> classBuilder, final String property, final CaseBlockBuilder switchBlock) { final MetaMethod getterMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); if (getterMethod != null && !getterMethod.isFinal() && getterMethod.isPublic()) { BlockBuilder<CaseBlockBuilder> caseBlock = switchBlock.case_(property); caseBlock.append(Stmt.loadVariable("this").invoke(getterMethod.getName()).returnValue()).finish(); classBuilder.publicMethod(getterMethod.getReturnType(), getterMethod.getName()) .append(target().invoke(getterMethod.getName()).returnValue()) .finish(); proxiedAccessorMethods.add(getterMethod); } }
agent("propertyTypes"))); for (final String property : bindable.getBeanDescriptor().getProperties()) { final MetaMethod readMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); if (isProxiable(readMethod)) { final MetaClass propertyType = readMethod.getReturnType();
agent("propertyTypes"))); for (final String property : bindable.getBeanDescriptor().getProperties()) { final MetaMethod readMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); if (isProxiable(readMethod)) { final MetaClass propertyType = readMethod.getReturnType();
final MetaMethod getterMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); final MetaMethod setterMethod = bindable.getBeanDescriptor().getWriteMethodForProperty(property); if (getterMethod != null && !getterMethod.isFinal() && getterMethod.isPublic() && setterMethod != null && !setterMethod.isFinal() && setterMethod.isPublic()) { final boolean propertyIsList = bindable.getBeanDescriptor().getPropertyType(property) .getFullyQualifiedName().equals(List.class.getName());
final MetaMethod getterMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); final MetaMethod setterMethod = bindable.getBeanDescriptor().getWriteMethodForProperty(property); if (getterMethod != null && !getterMethod.isFinal() && getterMethod.isPublic() && setterMethod != null && !setterMethod.isFinal() && setterMethod.isPublic()) { final boolean propertyIsList = bindable.getBeanDescriptor().getPropertyType(property) .getFullyQualifiedName().equals(List.class.getName());
block.addStatement(Stmt.declareFinalVariable(targetVar, bindable, Stmt.loadVariable("this").invoke("unwrap"))); for (final String property : bindable.getBeanDescriptor().getProperties()) { final MetaMethod readMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); final MetaMethod writeMethod = bindable.getBeanDescriptor().getWriteMethodForProperty(property); if (readMethod != null && writeMethod != null && readMethod.isPublic() && writeMethod.isPublic()) { final MetaClass type = readMethod.getReturnType();
block.addStatement(Stmt.declareFinalVariable(targetVar, bindable, Stmt.loadVariable("this").invoke("unwrap"))); for (final String property : bindable.getBeanDescriptor().getProperties()) { final MetaMethod readMethod = bindable.getBeanDescriptor().getReadMethodForProperty(property); final MetaMethod writeMethod = bindable.getBeanDescriptor().getWriteMethodForProperty(property); if (readMethod != null && writeMethod != null && readMethod.isPublic() && writeMethod.isPublic()) { final MetaClass type = readMethod.getReturnType();
CaseBlockBuilder setSwitchBlock = Stmt.switch_(loadVariable("property")); for (final String property : bindable.getBeanDescriptor().getProperties()) { generateGetter(classBuilder, property, getSwitchBlock); generateSetter(classBuilder, property, setSwitchBlock);
CaseBlockBuilder setSwitchBlock = Stmt.switch_(loadVariable("property")); for (final String property : bindable.getBeanDescriptor().getProperties()) { generateGetter(classBuilder, property, getSwitchBlock); generateSetter(classBuilder, property, setSwitchBlock);