Package com.mysema.codegen.model

Examples of com.mysema.codegen.model.ClassType


public class EntityTypeTest {

    @Test
    public void UncapSimpleName_Escaped() {
        ClassType typeModel = new ClassType(TypeCategory.ENTITY, Object.class);
        EntityType entityModel = new EntityType(typeModel);
        assertEquals("object", entityModel.getUncapSimpleName());

        entityModel.addProperty(new Property(entityModel, "object", typeModel));
        assertEquals("object1", entityModel.getUncapSimpleName());
View Full Code Here


        assertEquals("object1", entityModel.getUncapSimpleName());
    }

    @Test
    public void UncapSimpleName_Escaped2() {
        ClassType typeModel = new ClassType(TypeCategory.ENTITY, Object.class);
        EntityType entityModel = new EntityType(typeModel);
        assertEquals("object", entityModel.getUncapSimpleName());

        entityModel.addProperty(new Property(entityModel, "OBJECT", "object", typeModel,
                Collections.<String> emptyList(), false));
View Full Code Here

        assertEquals("object1", entityModel.getUncapSimpleName());
    }

    @Test
    public void UncapSimpleName_Escaped3() {
        ClassType typeModel = new ClassType(TypeCategory.ENTITY, Void.class);
        EntityType entityModel = new EntityType(typeModel);
        assertEquals("void$", entityModel.getUncapSimpleName());
    }
View Full Code Here

        if (Number.class.isAssignableFrom(clazz)) {
            fieldType = TypeCategory.NUMERIC;
        } else if (Enum.class.isAssignableFrom(clazz)) {
            fieldType = TypeCategory.ENUM;
        }
        Type typeModel = new ClassType(fieldType, clazz);
        Property property = createProperty(classModel, normalizedColumnName, propertyName, typeModel);
        ColumnMetadata column = ColumnMetadata.named(normalizedColumnName).ofType(columnType).withIndex(columnIndex);
        if (nullable == DatabaseMetaData.columnNoNulls) {
            column = column.notNull();
        }
View Full Code Here

    @Test
    public void CustomType() throws IOException{
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
        EntityType entityType = new EntityType(type);
        entityType.addProperty(new Property(entityType, "property", new ClassType(Double[].class)));
        typeMappings.register(new ClassType(Double[].class), new ClassType(Point.class));
        typeMappings.register(entityType, queryTypeFactory.create(entityType));
        assertTrue(typeMappings.isRegistered(entityType.getProperties().iterator().next().getType()));

        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        assertTrue(writer.toString().contains(
View Full Code Here

    static class Entity { }

    @Test
    public void GetPathType_Of_InnerClass() {
        TypeMappings typeMappings = new JavaTypeMappings();
        EntityType model = new EntityType(new ClassType(TypeMappingsTest.class));
        EntityType type = new EntityType(new ClassType(Entity.class));
        typeMappings.register(type, new QueryTypeFactoryImpl("Q","","").create(type));

        Type pathType = typeMappings.getPathType(type, model, false);
        assertEquals("QTypeMappingsTest_Entity", pathType.getSimpleName());
    }
View Full Code Here

    }

    @Test
    public void IsRegistered() {
        TypeMappings typeMappings = new JavaTypeMappings();
        typeMappings.register(new ClassType(Double[].class), new ClassType(Point.class));
        assertTrue(typeMappings.isRegistered(new ClassType(Double[].class)));

    }
View Full Code Here

        Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false, false);
        type = new EntityType(typeModel);

        // property
        type.addProperty(new Property(type, "entityField", type));
        type.addProperty(new Property(type, "collection", new ClassType(TypeCategory.COLLECTION, Collection.class, typeModel)));
        type.addProperty(new Property(type, "listField", new ClassType(TypeCategory.LIST, List.class, typeModel)));
        type.addProperty(new Property(type, "setField", new ClassType(TypeCategory.SET, Set.class, typeModel)));
        type.addProperty(new Property(type, "arrayField", new ClassType(TypeCategory.ARRAY, String[].class, typeModel)));
        type.addProperty(new Property(type, "mapField", new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)));
        type.addProperty(new Property(type, "superTypeField", new TypeExtends(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel))));
        type.addProperty(new Property(type, "extendsTypeField", new TypeSuper(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel))));

        for (Class<?> cl : Arrays.asList(Boolean.class, Comparable.class, Integer.class, Date.class, java.sql.Date.class, java.sql.Time.class)) {
            Type classType = new ClassType(TypeCategory.get(cl.getName()), cl);
            type.addProperty(new Property(type, StringUtils.uncapitalize(cl.getSimpleName()), classType));
        }

        // constructor
        Parameter firstName = new Parameter("firstName", new ClassType(TypeCategory.STRING, String.class));
        Parameter lastName = new Parameter("lastName", new ClassType(TypeCategory.STRING, String.class));
        type.addConstructor(new Constructor(Arrays.asList(firstName, lastName)));
    }
View Full Code Here

    public void register(TypeCategory category,
            @Nullable Class<? extends Expression> expr,
            @Nullable Class<? extends Path> path,
            @Nullable Class<? extends TemplateExpression> template) {
        if (expr != null) {
            exprTypes.put(category, new ClassType(expr));
        }
        if (path != null) {
            pathTypes.put(category, new ClassType(path));
        }
        if (template != null) {
            templateTypes.put(category, new ClassType(template));
        }
    }
View Full Code Here

            cl = Primitives.wrap(cl);
        }
        Type value;
        Type[] tempParams = (Type[]) Array.newInstance(Type.class,
                ReflectionUtils.getTypeParameterCount(genericType));
        cache.put(key, new ClassType(cl, tempParams));
        Type[] parameters = getParameters(cl, genericType);

        if (cl.isArray()) {
            Type componentType = get(cl.getComponentType());
            if (cl.getComponentType().isPrimitive()) {
                componentType = Types.PRIMITIVES.get(componentType);
            }
            value = componentType.asArrayType();
        } else if (cl.isEnum()) {
            value = new ClassType(TypeCategory.ENUM, cl);
        } else if (Number.class.isAssignableFrom(cl) && Comparable.class.isAssignableFrom(cl)) {
            value = new ClassType(TypeCategory.NUMERIC, cl, parameters);
        } else if (entity) {
            value = createOther(cl, entity, annotationHelper, annotation, parameters);
        } else if (Map.class.isAssignableFrom(cl)) {
            value = new SimpleType(Types.MAP, parameters[0], asGeneric(parameters[1]));
        } else if (List.class.isAssignableFrom(cl)) {
View Full Code Here

TOP

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

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.