Package com.mysema.codegen.model

Examples of com.mysema.codegen.model.SimpleType


                String entityName = ((OneToMany)collection.getElement()).getReferencedEntityName();
                if (entityName != null) {
                    if (collection.isMap()) {
                        Type keyType = typeFactory.get(Class.forName(propertyType.getParameters().get(0).getFullName()));
                        Type valueType = typeFactory.get(Class.forName(entityName));
                        propertyType = new SimpleType(propertyType,
                                normalize(propertyType.getParameters().get(0), keyType),
                                normalize(propertyType.getParameters().get(1), valueType));
                    } else {
                        Type componentType = typeFactory.get(Class.forName(entityName));
                        propertyType = new SimpleType(propertyType,
                                normalize(propertyType.getParameters().get(0), componentType));
                    }
                }
            } else if (collection.getElement() instanceof Component) {
                Component component = (Component)collection.getElement();
View Full Code Here


            if (p instanceof MapAttribute) {
                MapAttribute<?,?,?> map = (MapAttribute<?,?,?>)p;
                Type keyType = typeFactory.get(map.getKeyJavaType());
                Type valueType = typeFactory.get(map.getElementType().getJavaType());
                valueType = getPropertyType(p, valueType);
                propertyType = new SimpleType(propertyType,
                        normalize(propertyType.getParameters().get(0), keyType),
                        normalize(propertyType.getParameters().get(1), valueType));
            } else {
                Type valueType = typeFactory.get(((PluralAttribute<?,?,?>)p).getElementType().getJavaType());
                valueType = getPropertyType(p, valueType);
                propertyType = new SimpleType(propertyType,
                        normalize(propertyType.getParameters().get(0), valueType));
            }
        } else {
            propertyType = getPropertyType(p, propertyType);
        }
View Full Code Here

public class PropertyTest {

    @Test
    public void Equals_And_HashCode() {
        Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false,false);
        EntityType type = new EntityType(typeModel);
        Property p1 = new Property(type, "property", type, Collections.<String>emptyList());
        Property p2 = new Property(type, "property", type, Collections.<String>emptyList());
        assertEquals(p1, p1);
        assertEquals(p1, p2);
View Full Code Here

        assertEquals(p1.hashCode(), p2.hashCode());
    }

    @Test
    public void EscapedName() {
        Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false,false);
        EntityType type = new EntityType(typeModel);
        Property property = new Property(type, "boolean", type, Collections.<String>emptyList());
        assertEquals("boolean$", property.getEscapedName());
    }
View Full Code Here

            switch (join.getType()) {
            case DEFAULT:
                ser.append("for (" + typeName + " "+ target + " : " + target + "_) {\n");
                vars.append(target);
                sourceNames.add(target+"_");
                sourceTypes.add(new SimpleType(Types.ITERABLE, new ClassType(TypeCategory.SIMPLE,target.getType())));
                sourceClasses.add(Iterable.class);
                break;

            case INNERJOIN:
            case LEFTJOIN:
View Full Code Here

            "extends EntityPathBase<EntitySerializerTest.Entity>"));
    }
   
    @Test
    public void No_Package() throws IOException {
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
        EntityType entityType = new EntityType(type);
        typeMappings.register(entityType, queryTypeFactory.create(entityType));

        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        assertTrue(writer.toString().contains("public class QEntity extends EntityPathBase<Entity> {"));
View Full Code Here

        categoryToSuperClass.put(TypeCategory.NUMERIC, "NumberPath<Entity>");
        categoryToSuperClass.put(TypeCategory.STRING, "StringPath");
        categoryToSuperClass.put(TypeCategory.BOOLEAN, "BooleanPath");

        for (Map.Entry<TypeCategory, String> entry : categoryToSuperClass.entrySet()) {
            SimpleType type = new SimpleType(entry.getKey(), "Entity", "", "Entity",false,false);
            EntityType entityType = new EntityType(type);
            typeMappings.register(entityType, queryTypeFactory.create(entityType));

            serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
            assertTrue(entry.toString(), writer.toString().contains("public class QEntity extends "+entry.getValue()+" {"));
View Full Code Here

    }

    @Test
    public void Correct_Superclass() throws IOException {
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "java.util.Locale", "java.util", "Locale",false,false);
        EntityType entityType = new EntityType(type);
        typeMappings.register(entityType, queryTypeFactory.create(entityType));

        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
//        System.out.println(writer);
View Full Code Here

        assertTrue(writer.toString().contains("public class QLocale extends EntityPathBase<Locale> {"));
    }

    @Test
    public void Primitive_Array() throws IOException{
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
        EntityType entityType = new EntityType(type);
        entityType.addProperty(new Property(entityType, "bytes", new ClassType(byte[].class)));
        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        assertTrue(writer.toString().contains("public final SimplePath<byte[]> bytes"));
    }
View Full Code Here

        assertTrue(writer.toString().contains("public final SimplePath<byte[]> bytes"));
    }

    @Test
    public void Include() throws IOException{
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
        EntityType entityType = new EntityType(type);
        entityType.addProperty(new Property(entityType, "b", new ClassType(TypeCategory.BOOLEAN, Boolean.class)));
        entityType.addProperty(new Property(entityType, "c", new ClassType(TypeCategory.COMPARABLE, String.class)));
        entityType.addProperty(new Property(entityType, "cu", new ClassType(TypeCategory.CUSTOM, PropertyType.class)));
        entityType.addProperty(new Property(entityType, "d", new ClassType(TypeCategory.DATE, Date.class)));
        entityType.addProperty(new Property(entityType, "e", new ClassType(TypeCategory.ENUM, PropertyType.class)));
        entityType.addProperty(new Property(entityType, "dt", new ClassType(TypeCategory.DATETIME, Date.class)));
        entityType.addProperty(new Property(entityType, "i", new ClassType(TypeCategory.NUMERIC, Integer.class)));
        entityType.addProperty(new Property(entityType, "s", new ClassType(TypeCategory.STRING, String.class)));
        entityType.addProperty(new Property(entityType, "t", new ClassType(TypeCategory.TIME, Time.class)));

        EntityType subType = new EntityType(new SimpleType(TypeCategory.ENTITY, "Entity2", "", "Entity2",false,false));
        subType.include(new Supertype(type,entityType));

        serializer.serialize(subType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        // TODO : assertions
    }
View Full Code Here

TOP

Related Classes of com.mysema.codegen.model.SimpleType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.