As far I understand these annotations are representation of the same properties which can be used in XXX-conversion.properties files https://struts.apache.org/core-developers/type-conversion.html#collection-and-map-support
Regards -- Ćukasz + 48 606 323 122 http://www.lenart.org.pl/ 2018-01-03 19:42 GMT+01:00 Yasser Zamani <[email protected]>: > Hi there, happy new year :) > > During resolving WW-4906, I reached following difficulties with these > two classes and I need your comments if any, please: > > DefaultConversionAnnotationProcessor > >> public void process(Map<String, Object> mapping, TypeConversion tc, >> String key) { >> ... >> try { >> if (tc.type() == ConversionType.APPLICATION) { >> ... >> } else { >> if (tc.rule() == ConversionRule.KEY_PROPERTY || tc.rule() == >> ConversionRule.CREATE_IF_NULL) { > > If CREATE_IF_NULL and KEY_PROPERTY have same behavior, why they are two? > What makes difference? > >> mapping.put(key, tc.value()); > > I could not find any sample or doc about usage and advantages of > specifying value explicitly. > >> } >> //for properties of classes >> else if (tc.rule() != ConversionRule.ELEMENT || tc.rule() == >> ConversionRule.KEY || tc.rule() == ConversionRule.COLLECTION) { > > `tc.rule() != ConversionRule.ELEMENT` was enough i.e. next two ORs don't > make any difference. Or maybe it's wrong and next two ORs should being > keeped? > >> ... >> } >> //for keys of Maps >> else if (tc.rule() == ConversionRule.KEY) { > > Execution never reaches inside this block. Here 100% tc.rule() is > ConversionRule.ELEMENT because of previous if. And also why previous if > also has this in it's ORs? > > Again, I could not find any sample or doc about usage and advantages of > this block! (following lines). > >> Class<?> converterClass; >> if (StringUtils.isNoneEmpty(tc.converter())) { >> converterClass = >> Thread.currentThread().getContextClassLoader().loadClass(tc.converter()); >> //check if the converter is a type converter if it >> is one >> //then just put it in the map as is. Otherwise >> //put a value in for the type converter of the class >> } else { >> converterClass = tc.converterClass(); >> } >> >> LOG.debug("Converter class: [{}]", converterClass); >> >> if >> (converterClass.isAssignableFrom(TypeConverter.class)) { >> mapping.put(key, >> converterCreator.createTypeConverter(tc.converter())); >> } else { >> mapping.put(key, converterClass); >> LOG.debug("Object placed in mapping for key [{}] is >> [{}]", key, mapping.get(key)); >> } >> } >> //elements(values) of maps / lists >> else { > > Again, I could not find any sample or doc about usage and advantages of > this block! (following lines). > >> if (StringUtils.isNoneEmpty(tc.converter())) { >> mapping.put(key, >> Thread.currentThread().getContextClassLoader().loadClass(tc.converter())); >> } else { >> mapping.put(key, tc.converterClass()); >> } >> } >> } >> } catch (Exception e) { >> LOG.debug("Got exception for {}", key, e); >> } >> } > > > ConversionRule > >> public enum ConversionRule { >> >> PROPERTY, COLLECTION, MAP, KEY, KEY_PROPERTY, ELEMENT, CREATE_IF_NULL; > > Again, I could not find any comprehensive sample or doc about usage and > advantages of each one! > > > Thanks in advance! > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
