"scott.stark(a)jboss.org" wrote : This is implemented in the metavalue project now.
I think you are again doing it wrong, as with SimpleMetaValueComparator.
You should add this info to SimpleMetaType.
As you have all the info required in AbstractInstanceClassFactory::setValue.
| protected void setValue(BeanInfo beanInfo, PropertyInfo propertyInfo, Object object, Object unwrapValue)
| throws Throwable
| {
| TypeInfo type = propertyInfo.getType();
| if(unwrapValue == null && type.isPrimitive())
| {
| MetaType metaType = MetaTypeFactory.getInstance().resolve(type);
| SimpleMetaType smt = SimpleMetaType.class.cast(metaType);
| unwrapValue = smt.getDefaultValue(); // <-- missing method
| }
| propertyInfo.set(object, unwrapValue);
| }
|
More OO.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191439#4191439
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191439
Checking how KernelDeployment handles BeanMetaDataFactorys I came with the following issue:
- http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191432#4191432
I guess CollectionPropertyHandler could include this check
| if (child != null)
| {
| TypeInfo typeInfo = propertyInfo.getType();
| if (typeInfo instanceof ClassInfo)
| {
| ClassInfo classInfo = (ClassInfo)typeInfo;
| TypeInfo componentType = classInfo.getComponentType();
| if (componentType != null)
| {
| TypeInfoFactory tif = componentType.getTypeInfoFactory();
| TypeInfo childTypeInfo = tif.getTypeInfo(child.getClass());
| if (componentType.isAssignableFrom(childTypeInfo) == false)
| throw new IllegalArgumentException("Illegal child type");
| }
| }
| }
|
probably in a bit more optimized way - not checking for component type every time.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191434#4191434
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191434
"scott.stark(a)jboss.org" wrote : That's a valid question.
Thinking about it some more,
I think it's not the job of PropertyInfo/MethodInfo to recognize primitive type + default value,
they should just do what they are instructed - as it is currently implemented.
It should be the code that's using it, that should know what to do.
In your case it's meta value/type, in kernel's case it's configure action.
I'll check how this behaves in MC-Kernel code.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191429#4191429
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191429