private Method checkGetter(Method method) { if (method != null) { int modifiers = method.getModifiers(); if (!Modifier.isPublic(modifiers)) { throw new IllegalArgumentException("Modifier for getter method should be public"); } Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 0) { throw new IllegalArgumentException("Number of parameters in getter method is not equal to 0"); } Class<?> returnType = method.getReturnType(); if (returnType.equals(Void.TYPE)) { throw new IllegalArgumentException("Getter has return type void"); } Class<?> propertyType = getPropertyType(); if (propertyType != null && !returnType.equals(propertyType)) { throw new IllegalArgumentException("Parameter type in getter does not correspond to setter"); } } return method; }
private Method checkSetter(Method method) { if (method != null) { int modifiers = method.getModifiers(); if (!Modifier.isPublic(modifiers)) { throw new IllegalArgumentException("Modifier for setter method should be public"); } Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { throw new IllegalArgumentException("Number of parameters in setter method is not equal to 1"); } Class<?> parameterType = parameterTypes[0]; Class<?> propertyType = getPropertyType(); if (propertyType != null && !propertyType.equals(parameterType)) { throw new IllegalArgumentException("Parameter type in setter does not correspond to getter"); } } return method; } }
private Method checkSetter(Method method) { if (method != null) { int modifiers = method.getModifiers(); if (!Modifier.isPublic(modifiers)) { throw new IllegalArgumentException("Modifier for setter method should be public"); } Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { throw new IllegalArgumentException("Number of parameters in setter method is not equal to 1"); } Class<?> parameterType = parameterTypes[0]; Class<?> propertyType = getPropertyType(); if (propertyType != null && !propertyType.equals(parameterType)) { throw new IllegalArgumentException("Parameter type in setter does not correspond to getter"); } } return method; } }
private Method checkGetter(Method method) { if (method != null) { int modifiers = method.getModifiers(); if (!Modifier.isPublic(modifiers)) { throw new IllegalArgumentException("Modifier for getter method should be public"); } Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 0) { throw new IllegalArgumentException("Number of parameters in getter method is not equal to 0"); } Class<?> returnType = method.getReturnType(); if (returnType.equals(Void.TYPE)) { throw new IllegalArgumentException("Getter has return type void"); } Class<?> propertyType = getPropertyType(); if (propertyType != null && !returnType.equals(propertyType)) { throw new IllegalArgumentException("Parameter type in getter does not correspond to setter"); } } return method; }
if (pd.getPropertyType() == Integer.class || pd.getPropertyType().getComponentType() == Integer.class) { tagValue = new Integer(GoogleBaseParser.stripNonValidCharacters(GoogleBaseParser.INTEGER_CHARS, tag.getText())); } else if (pd.getPropertyType() == Float.class || pd.getPropertyType().getComponentType() == Float.class) { tagValue = new Float(GoogleBaseParser.stripNonValidCharacters(GoogleBaseParser.FLOAT_CHARS, tag.getText())); } else if (pd.getPropertyType() == String.class || pd.getPropertyType().getComponentType() == String.class) { tagValue = tag.getText(); } else if (pd.getPropertyType() == URL.class || pd.getPropertyType().getComponentType() == URL.class) { tagValue = new URL(tag.getText().trim()); } else if (pd.getPropertyType() == Boolean.class || pd.getPropertyType().getComponentType() == Boolean.class) { tagValue = new Boolean(tag.getText().trim()); } else if (pd.getPropertyType() == Date.class || pd.getPropertyType().getComponentType() == Date.class) { final String text = tag.getText().trim(); } else if (pd.getPropertyType() == IntUnit.class || pd.getPropertyType().getComponentType() == IntUnit.class) { tagValue = new IntUnit(tag.getText()); } else if (pd.getPropertyType() == FloatUnit.class || pd.getPropertyType().getComponentType() == FloatUnit.class) { tagValue = new FloatUnit(tag.getText()); } else if (pd.getPropertyType() == DateTimeRange.class || pd.getPropertyType().getComponentType() == DateTimeRange.class) { tagValue = new DateTimeRange(LONG_DT_FMT.parse(tag.getChild("start", GoogleBaseParser.NS).getText().trim()), LONG_DT_FMT.parse(tag .getChild("end", GoogleBaseParser.NS).getText().trim())); } else if (pd.getPropertyType() == ShippingType.class || pd.getPropertyType().getComponentType() == ShippingType.class) { final FloatUnit price = new FloatUnit(tag.getChild("price", GoogleBaseParser.NS).getText().trim()); ShippingType.ServiceEnumeration service = } else if (pd.getPropertyType() == PaymentTypeEnumeration.class || pd.getPropertyType().getComponentType() == PaymentTypeEnumeration.class) { tagValue = PaymentTypeEnumeration.findByValue(tag.getText().trim()); } else if (pd.getPropertyType() == PriceTypeEnumeration.class || pd.getPropertyType().getComponentType() == PriceTypeEnumeration.class) { tagValue = PriceTypeEnumeration.findByValue(tag.getText().trim());
if (pd.getPropertyType() == Integer.class || pd.getPropertyType().getComponentType() == Integer.class) { tagValue = new Integer(GoogleBaseParser.stripNonValidCharacters(GoogleBaseParser.INTEGER_CHARS, tag.getText())); } else if (pd.getPropertyType() == Float.class || pd.getPropertyType().getComponentType() == Float.class) { tagValue = new Float(GoogleBaseParser.stripNonValidCharacters(GoogleBaseParser.FLOAT_CHARS, tag.getText())); } else if (pd.getPropertyType() == String.class || pd.getPropertyType().getComponentType() == String.class) { tagValue = tag.getText(); } else if (pd.getPropertyType() == URL.class || pd.getPropertyType().getComponentType() == URL.class) { tagValue = new URL(tag.getText().trim()); } else if (pd.getPropertyType() == Boolean.class || pd.getPropertyType().getComponentType() == Boolean.class) { tagValue = new Boolean(tag.getText().trim()); } else if (pd.getPropertyType() == Date.class || pd.getPropertyType().getComponentType() == Date.class) { final String text = tag.getText().trim(); } else if (pd.getPropertyType() == IntUnit.class || pd.getPropertyType().getComponentType() == IntUnit.class) { tagValue = new IntUnit(tag.getText()); } else if (pd.getPropertyType() == FloatUnit.class || pd.getPropertyType().getComponentType() == FloatUnit.class) { tagValue = new FloatUnit(tag.getText()); } else if (pd.getPropertyType() == DateTimeRange.class || pd.getPropertyType().getComponentType() == DateTimeRange.class) { tagValue = new DateTimeRange(LONG_DT_FMT.parse(tag.getChild("start", GoogleBaseParser.NS).getText().trim()), LONG_DT_FMT.parse(tag .getChild("end", GoogleBaseParser.NS).getText().trim())); } else if (pd.getPropertyType() == ShippingType.class || pd.getPropertyType().getComponentType() == ShippingType.class) { final FloatUnit price = new FloatUnit(tag.getChild("price", GoogleBaseParser.NS).getText().trim()); ShippingType.ServiceEnumeration service = } else if (pd.getPropertyType() == PaymentTypeEnumeration.class || pd.getPropertyType().getComponentType() == PaymentTypeEnumeration.class) { tagValue = PaymentTypeEnumeration.findByValue(tag.getText().trim()); } else if (pd.getPropertyType() == PriceTypeEnumeration.class || pd.getPropertyType().getComponentType() == PriceTypeEnumeration.class) { tagValue = PriceTypeEnumeration.findByValue(tag.getText().trim());
@Override public void generate(final Module module, final Element element) { final GoogleBaseImpl mod = (GoogleBaseImpl) module; final HashMap<Object, Object> props2tags = new HashMap<Object, Object>(GoogleBaseParser.PROPS2TAGS); final List<PropertyDescriptor> pds = GoogleBaseParser.pds; for (final PropertyDescriptor pd : pds) { final String tagName = (String) props2tags.get(pd.getName()); if (tagName == null) { continue; } Object[] values = null; try { if (pd.getPropertyType().isArray()) { values = (Object[]) pd.getReadMethod().invoke(mod, (Object[]) null); } else { values = new Object[] {pd.getReadMethod().invoke(mod, (Object[]) null)}; } for (int j = 0; values != null && j < values.length; j++) { if (values[j] != null) { element.addContent(generateTag(values[j], tagName)); } } } catch (final Exception e) { LOG.error("Error", e); } } }
@Override public void generate(final Module module, final Element element) { final GoogleBaseImpl mod = (GoogleBaseImpl) module; final HashMap<Object, Object> props2tags = new HashMap<Object, Object>(GoogleBaseParser.PROPS2TAGS); final List<PropertyDescriptor> pds = GoogleBaseParser.pds; for (final PropertyDescriptor pd : pds) { final String tagName = (String) props2tags.get(pd.getName()); if (tagName == null) { continue; } Object[] values = null; try { if (pd.getPropertyType().isArray()) { values = (Object[]) pd.getReadMethod().invoke(mod, (Object[]) null); } else { values = new Object[] {pd.getReadMethod().invoke(mod, (Object[]) null)}; } for (int j = 0; values != null && j < values.length; j++) { if (values[j] != null) { element.addContent(generateTag(values[j], tagName)); } } } catch (final Exception e) { LOG.error("Error", e); } } }