[jboss-jira] [JBoss JIRA] Resolved: (JBMICROCONT-238) Add MapCompositeMetaType support
Scott M Stark (JIRA)
jira-events at lists.jboss.org
Thu Mar 6 17:01:58 EST 2008
[ http://jira.jboss.com/jira/browse/JBMICROCONT-238?page=all ]
Scott M Stark resolved JBMICROCONT-238.
---------------------------------------
Resolution: Done
Both java.util.Map<String,?> types as well as java.util.Properties now resolve to MapCompositeMetaType:
public void testMapWithStringKeyComposite() throws Exception
{
//Map<String,String> map = new HashMap<String,String>();
Field field = getClass().getField("compositeSignature");
Type mapSignature = field.getGenericType();
CompositeMetaType result = assertInstanceOf(resolve(mapSignature), CompositeMetaType.class);
MapCompositeMetaType expected = new MapCompositeMetaType(SimpleMetaType.STRING);
testComposite(expected, result);
}
public void testPropertiesComposite()
throws Exception
{
Type propertiesType = Properties.class;
CompositeMetaType result = assertInstanceOf(resolve(propertiesType), CompositeMetaType.class);
MapCompositeMetaType expected = new MapCompositeMetaType(SimpleMetaType.STRING);
testComposite(expected, result);
}
Note that obtaining the type from a value still resolves to TableMetaType since the generic type information cannot be determined:
/**
* Illustrate the expected type when type does not contain the
* generic parameter type information.
*/
public void testMapWithStringKeyErasure()
throws Exception
{
Map<String,String> map = new HashMap<String,String>();
Type mapSignature = map.getClass();
TableMetaType result = assertInstanceOf(resolve(mapSignature), TableMetaType.class);
MetaType keyType = resolve(Object.class);
MetaType valueType = resolve(Object.class);
MetaType[] itemTypes = { keyType, valueType };
String entryName = Map.Entry.class.getName();
CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
TableMetaType expected = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
assertEquals(expected, result);
}
> Add MapCompositeMetaType support
> --------------------------------
>
> Key: JBMICROCONT-238
> URL: http://jira.jboss.com/jira/browse/JBMICROCONT-238
> Project: JBoss MicroContainer
> Issue Type: Task
> Components: Metatype
> Affects Versions: JBossMC-2.0.0.Beta10
> Reporter: Scott M Stark
> Assigned To: Scott M Stark
> Fix For: JBossMC-2.0.0.CR1
>
>
> Right now MetaTypeFactory.resolve(Map[String,?].class) returns a TableMetaType. It seems more natural for this to be a CompositeMetaType that does not restrict the item names when the Map has String keys.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list