use of javax.lang.model.type.TypeMirror in project hibernate-orm by hibernate.
the class BasicAttributeVisitor method visitExecutable.
@Override
public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element p) {
if (!p.getKind().equals(ElementKind.METHOD)) {
return null;
}
String string = p.getSimpleName().toString();
if (!StringUtil.isProperty(string, TypeUtils.toTypeString(t.getReturnType()))) {
return null;
}
TypeMirror returnType = t.getReturnType();
return returnType.accept(this, p);
}
use of javax.lang.model.type.TypeMirror in project hibernate-orm by hibernate.
the class BasicAttributeVisitor method visitTypeVariable.
@Override
public AnnotationMetaAttribute visitTypeVariable(TypeVariable t, Element element) {
// METAGEN-29 - for a type variable we use the upper bound
TypeMirror mirror = t.getUpperBound();
TypeMirror erasedType = context.getTypeUtils().erasure(mirror);
return new AnnotationMetaSingleAttribute(entity, element, erasedType.toString());
}
use of javax.lang.model.type.TypeMirror in project hibernate-orm by hibernate.
the class BasicAttributeVisitor method getFullyQualifiedClassNameOfTargetEntity.
private String getFullyQualifiedClassNameOfTargetEntity(AnnotationMirror mirror, String parameterName) {
assert mirror != null;
assert parameterName != null;
String targetEntityName = null;
Object parameterValue = TypeUtils.getAnnotationValue(mirror, parameterName);
if (parameterValue != null) {
TypeMirror parameterType = (TypeMirror) parameterValue;
if (!parameterType.getKind().equals(TypeKind.VOID)) {
targetEntityName = parameterType.toString();
}
}
return targetEntityName;
}
use of javax.lang.model.type.TypeMirror in project hibernate-orm by hibernate.
the class XmlMetaEntity method getType.
/**
* Returns the entity type for a property.
*
* @param propertyName The property name
* @param explicitTargetEntity The explicitly specified target entity type or {@code null}.
* @param expectedElementKind Determines property vs field access type
*
* @return The entity type for this property or {@code null} if the property with the name and the matching access
* type does not exist.
*/
private String getType(String propertyName, String explicitTargetEntity, ElementKind expectedElementKind) {
for (Element elem : element.getEnclosedElements()) {
if (!expectedElementKind.equals(elem.getKind())) {
continue;
}
TypeMirror mirror;
String name = elem.getSimpleName().toString();
if (ElementKind.METHOD.equals(elem.getKind())) {
name = StringUtil.getPropertyName(name);
mirror = ((ExecutableElement) elem).getReturnType();
} else {
mirror = elem.asType();
}
if (name == null || !name.equals(propertyName)) {
continue;
}
if (explicitTargetEntity != null) {
// TODO should there be a check of the target entity class and if it is loadable?
return explicitTargetEntity;
}
switch(mirror.getKind()) {
case INT:
{
return "java.lang.Integer";
}
case LONG:
{
return "java.lang.Long";
}
case BOOLEAN:
{
return "java.lang.Boolean";
}
case BYTE:
{
return "java.lang.Byte";
}
case SHORT:
{
return "java.lang.Short";
}
case CHAR:
{
return "java.lang.Char";
}
case FLOAT:
{
return "java.lang.Float";
}
case DOUBLE:
{
return "java.lang.Double";
}
case DECLARED:
{
return mirror.toString();
}
case TYPEVAR:
{
return mirror.toString();
}
default:
{
}
}
}
context.logMessage(Diagnostic.Kind.WARNING, "Unable to determine type for property " + propertyName + " of class " + getQualifiedName() + " using access type " + accessTypeInfo.getDefaultAccessType());
return null;
}
use of javax.lang.model.type.TypeMirror in project neo4j by neo4j.
the class ServiceProcessor method process.
@SuppressWarnings("unchecked")
@Override
protected void process(TypeElement annotationType, Element annotated, AnnotationMirror annotation, Map<? extends ExecutableElement, ? extends AnnotationValue> values) throws IOException {
for (AnnotationValue o : (List<? extends AnnotationValue>) values.values().iterator().next().getValue()) {
TypeMirror service = (TypeMirror) o.getValue();
addTo(((TypeElement) annotated).getQualifiedName().toString(), "META-INF", "services", service.toString());
}
}
Aggregations