@Nullable private Property createProperty(EntityType entityType, String propertyName, Type propertyType, AnnotatedElement annotated) { List<String> inits = Collections.emptyList(); if (annotated.isAnnotationPresent(skipAnnotation) && !annotated.isAnnotationPresent(QueryType.class)) { return null; } if (annotated.isAnnotationPresent(QueryInit.class)) { inits = ImmutableList.copyOf(annotated.getAnnotation(QueryInit.class).value()); } if (annotated.isAnnotationPresent(QueryType.class)) { QueryType queryType = annotated.getAnnotation(QueryType.class); if (queryType.value().equals(PropertyType.NONE)) { return null; } propertyType = propertyType.as(TypeCategory.valueOf(queryType.value().name())); } return new Property(entityType, propertyName, propertyType, inits); }
private void addConstructors(Class<?> cl, EntityType type) { for (Constructor<?> constructor : cl.getConstructors()) { if (constructor.isAnnotationPresent(QueryProjection.class)) { List<Parameter> parameters = Lists.newArrayList(); for (int i = 0; i < constructor.getParameterTypes().length; i++) { Type parameterType = typeFactory.get( constructor.getParameterTypes()[i], constructor.getGenericParameterTypes()[i]); for (Annotation annotation : constructor.getParameterAnnotations()[i]) { if (annotation.annotationType().equals(QueryType.class)) { QueryType queryType = (QueryType) annotation; parameterType = parameterType.as(TypeCategory.valueOf(queryType.value().name())); } } parameters.add(new Parameter("param" + i, parameterType)); } type.addConstructor(new com.mysema.codegen.model.Constructor(parameters)); } } }
public EntityType handleProjectionType(TypeElement e) { Type c = typeFactory.getType(e.asType(), true); EntityType entityType = new EntityType(c.as(TypeCategory.ENTITY), configuration.getVariableNameFunction()); typeMappings.register(entityType, queryTypeFactory.create(entityType)); List<? extends Element> elements = e.getEnclosedElements(); handleConstructors(entityType, elements); return entityType; }
private Type getType(VariableElement element) { Type rv = typeFactory.getType(element.asType(), true); if (element.getAnnotation(QueryType.class) != null) { QueryType qt = element.getAnnotation(QueryType.class); if (qt.value() != PropertyType.NONE) { TypeCategory typeCategory = TypeCategory.valueOf(qt.value().name()); rv = rv.as(typeCategory); } } return rv; }
private Property toProperty(EntityType entityType, String name, TypeMirror type, Annotations annotations) { // type Type propertyType = typeFactory.getType(type, true); if (annotations.isAnnotationPresent(QueryType.class)) { PropertyType propertyTypeAnn = annotations.getAnnotation(QueryType.class).value(); if (propertyTypeAnn != PropertyType.NONE) { TypeCategory typeCategory = TypeCategory.valueOf(annotations.getAnnotation(QueryType.class).value().name()); if (typeCategory == null) { return null; } propertyType = propertyType.as(typeCategory); } else { return null; } } // inits List<String> inits = Collections.emptyList(); if (annotations.isAnnotationPresent(QueryInit.class)) { inits = ImmutableList.copyOf(annotations.getAnnotation(QueryInit.class).value()); } return new Property(entityType, name, propertyType, inits); }
@Override public Type as(TypeCategory category) { return type.as(category); }
private Type getPropertyType(Attribute<?, ?> p, Type propertyType) { Temporal temporal = ((AnnotatedElement)p.getJavaMember()).getAnnotation(Temporal.class); if (temporal != null) { switch (temporal.value()) { case DATE: propertyType = propertyType.as(TypeCategory.DATE); break; case TIME: propertyType = propertyType.as(TypeCategory.TIME); break; case TIMESTAMP: propertyType = propertyType.as(TypeCategory.DATETIME); break; } } return propertyType; }
private Type getPropertyType(Attribute<?, ?> p, Type propertyType) { Temporal temporal = ((AnnotatedElement) p.getJavaMember()).getAnnotation(Temporal.class); if (temporal != null) { switch (temporal.value()) { case DATE: propertyType = propertyType.as(TypeCategory.DATE); break; case TIME: propertyType = propertyType.as(TypeCategory.TIME); break; case TIMESTAMP: propertyType = propertyType.as(TypeCategory.DATETIME); break; } } return propertyType; }
private Type getPropertyType(org.hibernate.mapping.Property p, Type propertyType) { switch (propertyType.getCategory()) { case DATE: case TIME: case DATETIME: String type = p.getType().getName(); if ("time".equals(type)) { propertyType = propertyType.as(TypeCategory.TIME); } else if ("date".equals(type)) { propertyType = propertyType.as(TypeCategory.DATE); } else if ("timestamp".equals(type)) { propertyType = propertyType.as(TypeCategory.DATETIME); } default: } return propertyType; }
private Type getPropertyType(org.hibernate.mapping.Property p, Type propertyType) { switch (propertyType.getCategory()) { case DATE: case TIME: case DATETIME: String type = p.getType().getName(); if ("time".equals(type)) { propertyType = propertyType.as(TypeCategory.TIME); } else if ("date".equals(type)) { propertyType = propertyType.as(TypeCategory.DATE); } else if ("timestamp".equals(type)) { propertyType = propertyType.as(TypeCategory.DATETIME); } default: } return propertyType; }
private Property createProperty(EntityType entityType, String propertyName, Type propertyType, Map<Class<? extends Annotation>, Annotation> annotations) { String[] inits = new String[0]; if (annotations.containsKey(QueryInit.class)) { inits = ((QueryInit) annotations.get(QueryInit.class)).value(); } if (annotations.containsKey(QueryType.class)) { propertyType = propertyType.as(TypeCategory.valueOf(((QueryType) annotations.get(QueryType.class)).value().name())); } Property property = new Property(entityType, propertyName, propertyType, Arrays.asList(inits)); return property; }
@Nullable protected Type getTypeOverride(Type propertyType, AnnotatedElement annotated) { if (annotated.isAnnotationPresent(QueryType.class)) { QueryType queryType = annotated.getAnnotation(QueryType.class); if (queryType.value().equals(PropertyType.NONE)) { return null; } return propertyType.as(TypeCategory.valueOf(queryType.value().name())); } else { return propertyType; } }
@Nullable protected Type getTypeOverride(Type propertyType, AnnotatedElement annotated) { if (annotated.isAnnotationPresent(QueryType.class)) { QueryType queryType = annotated.getAnnotation(QueryType.class); if (queryType.value().equals(PropertyType.NONE)) { return null; } return propertyType.as(TypeCategory.valueOf(queryType.value().name())); } else { return propertyType; } }