@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)); } } }
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); }
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; } }