Search in sources :

Example 1 with MapType

use of org.apache.cxf.aegis.type.collection.MapType in project cxf by apache.

the class MapTest method testType.

@Test
public void testType() throws Exception {
    Method m = MapService.class.getMethod("getMap", new Class[0]);
    AegisType type = creator.createType(m, -1);
    tm.register(type);
    assertTrue(type instanceof MapType);
    MapType mapType = (MapType) type;
    QName keyName = mapType.getKeyName();
    assertNotNull(keyName);
    type = mapType.getKeyType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(String.class));
    type = mapType.getValueType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(Integer.class));
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) Method(java.lang.reflect.Method) MapType(org.apache.cxf.aegis.type.collection.MapType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 2 with MapType

use of org.apache.cxf.aegis.type.collection.MapType in project cxf by apache.

the class MapTest method testPDType.

@Test
public void testPDType() throws Exception {
    PropertyDescriptor pd = Introspector.getBeanInfo(MapDTO.class, Object.class).getPropertyDescriptors()[0];
    AegisType type = creator.createType(pd);
    tm.register(type);
    assertTrue(type instanceof MapType);
    MapType mapType = (MapType) type;
    QName keyName = mapType.getKeyName();
    assertNotNull(keyName);
    type = mapType.getKeyType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(String.class));
    type = mapType.getValueType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(Integer.class));
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) MapType(org.apache.cxf.aegis.type.collection.MapType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 3 with MapType

use of org.apache.cxf.aegis.type.collection.MapType in project cxf by apache.

the class MapTest method testMapDTO.

@Test
public void testMapDTO() {
    tm = new DefaultTypeMapping();
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);
    AegisType dto = creator.createType(MapDTO.class);
    Set<AegisType> deps = dto.getDependencies();
    AegisType type = deps.iterator().next();
    assertTrue(type instanceof MapType);
    MapType mapType = (MapType) type;
    deps = dto.getDependencies();
    assertEquals(1, deps.size());
    type = mapType.getKeyType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(String.class));
    type = mapType.getValueType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(Integer.class));
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) AegisType(org.apache.cxf.aegis.type.AegisType) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) MapType(org.apache.cxf.aegis.type.collection.MapType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 4 with MapType

use of org.apache.cxf.aegis.type.collection.MapType in project cxf by apache.

the class AbstractTypeCreator method createMapType.

protected AegisType createMapType(TypeClassInfo info, AegisType keyType, AegisType valueType) {
    QName schemaType = createMapQName(info, keyType, valueType);
    MapType type = new MapType(schemaType, keyType, valueType);
    type.setTypeMapping(getTypeMapping());
    type.setTypeClass(info.getType());
    return type;
}
Also used : QName(javax.xml.namespace.QName) MapType(org.apache.cxf.aegis.type.collection.MapType)

Example 5 with MapType

use of org.apache.cxf.aegis.type.collection.MapType in project qi4j-sdk by Qi4j.

the class ValueCompositeCxfType method createType.

private AegisType createType(Type type, XmlSchema root) {
    if (isCollection(type)) {
        AegisType componentType = getOrCreateAegisType(getCollectionComponentType(type), root);
        CollectionType resultType = new CollectionType(componentType);
        QName schemaType = new QName("http://www.w3.org/2001/XMLSchema", "list");
        resultType.setSchemaType(schemaType);
        return resultType;
    } else if (isMap(type)) {
        AegisType keyType = getOrCreateAegisType(getMapKeyComponentType(type), root);
        AegisType valueType = getOrCreateAegisType(getMapValueComponentType(type), root);
        QName schemaType = new QName(Classes.toURI(Classes.RAW_CLASS.map(type)), "map");
        return new MapType(schemaType, keyType, valueType);
    } else if (isValueComposite(type)) {
        ValueCompositeCxfType aegisType = module.newObject(ValueCompositeCxfType.class, getTypeMapping(), type);
        getTypeMapping().register(aegisType);
        return aegisType;
    } else {
        throw new NoSuchValueException(type.toString(), module.name());
    }
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) CollectionType(org.apache.cxf.aegis.type.collection.CollectionType) MapType(org.apache.cxf.aegis.type.collection.MapType)

Aggregations

MapType (org.apache.cxf.aegis.type.collection.MapType)7 AegisType (org.apache.cxf.aegis.type.AegisType)6 QName (javax.xml.namespace.QName)5 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)5 Test (org.junit.Test)5 Method (java.lang.reflect.Method)3 CollectionType (org.apache.cxf.aegis.type.collection.CollectionType)2 PropertyDescriptor (java.beans.PropertyDescriptor)1 DefaultTypeMapping (org.apache.cxf.aegis.type.DefaultTypeMapping)1 TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)1