public String getCanonicalName() { if (enclosedClass != null) { return enclosedClass.getCanonicalName() + "." + simpleName; } return (packageName != null ? (packageName + ".") : "") + simpleName; }; //TODO: check if there should be $ or dot
@Override public int compare(MutableDeclaredType o1, MutableDeclaredType o2) { return o1.getCanonicalName().compareTo(o2.getCanonicalName()); }
protected MutableAnnotationMirror get(List<MutableAnnotationMirror> annotations, AnnotationMirror annotation) { for (MutableAnnotationMirror annotationMirror: annotations) { if (annotationMirror.getAnnotationType().getCanonicalName().equals(annotation.getAnnotationType().toString())) { return annotationMirror; } } return null; }
public String getQualifiedName() { if (enclosedClass != null) { return enclosedClass.getCanonicalName() + "$" + simpleName; } return getCanonicalName(); };
@Override public String getCanonicalName() { return ensureDelegateType().getCanonicalName(); }
protected String getImportPackage(MutableDeclaredType importType) { return importType.getCanonicalName().replace("." + importType.getSimpleName(), ""); }
protected AnnotationMirror[] getAnnotationMirrors(VariableElement field) { List<AnnotationMirror> result = new ArrayList<AnnotationMirror>(); List<? extends AnnotationMirror> annotationMirrors = field.getAnnotationMirrors(); MutableDeclaredType[] supportedAnnotations = getMergedConfiguration(DefaultConfigurationElement.PROCESSING_ANNOTATIONS); for (AnnotationMirror annotation: annotationMirrors) { for (MutableDeclaredType supportedAnnotaion: supportedAnnotations) { if (annotation.getAnnotationType().toString().equals(supportedAnnotaion.getCanonicalName())) { result.add(annotation); } } } return result.toArray(new AnnotationMirror[] {}); }
@SuppressWarnings("unchecked") public static <T, S extends T> List<? extends T> addUnique(List<? extends T> source, S t) { if (t == null) { return source; } String canonicalName = t.toString(); if (t instanceof MutableDeclaredType) { canonicalName = ((MutableDeclaredType)t).getCanonicalName(); } else if (t instanceof Class) { canonicalName = ((Class<?>)t).getCanonicalName(); } for (T s : source) { String sourceName = t.toString(); if (s instanceof MutableDeclaredType) { sourceName = ((MutableDeclaredType)s).getCanonicalName(); } else if (s instanceof Class) { sourceName = ((Class<?>)s).getCanonicalName(); } if (sourceName.equals(canonicalName)) { return source; } } ((List<T>)source).add(t); return source; }
protected TypeElement toTypeElement(MutableDeclaredType type) { return processingEnv.getElementUtils().getTypeElement(type.getCanonicalName()); } }
MutableDeclaredType dt2 = (MutableDeclaredType)t2; if (dt1.getCanonicalName().equals(dt2.getCanonicalName())) { return true; if (((MutableDeclaredType)interfaceType).getCanonicalName().equals(dt2.getCanonicalName())) { return true; if (((MutableDeclaredType)superClassType).getCanonicalName().equals(dt2.getCanonicalName())) { return true;
private String getImportPackage(MutableDeclaredType type) { if (type.getEnclosedClass() != null) { return type.getEnclosedClass().getCanonicalName(); } return type.getPackageName(); };
private int processElements(Collection<MutableDeclaredType> elements) { Map<String, Element> els = new HashMap<String, Element>(); for (MutableDeclaredType element: elements) { els.put(element.getCanonicalName(), processingEnv.getElementUtils().getTypeElement(element.toString(ClassSerializer.CANONICAL, false))); } int processedElementCount = 0; for (MutableDeclaredType element: elements) { if (!ListUtils.containsElement(processedElements, element)) { Element el = els.get(element.getCanonicalName()); if (el == null) { processingEnv.getMessager().printMessage(Kind.ERROR, "Element " + element.toString() + " is not available for the processing!"); } else { if (configurer == null || configurer.isSupportedKind(el.getKind())) { if (processedElements.size() == 0 || !getExecutionType().equals(ExecutionType.ONCE)) { processedElements.add(element); init(el, roundEnv); processedElementCount += processElement(element, roundEnv); configurer.flushMessages(processingEnv.getMessager(), el); } } } } } return processedElementCount; }
protected DomainType getDomainForType(TypeMirror type) { if (type.getKind().equals(TypeKind.DECLARED)) { List<MutableDeclaredType> domainDataTypes = new DataTypeResolver(environmentContext).getDomainData((MutableDeclaredType) environmentContext.getProcessingEnv().getTypeUtils().toMutableType(type)); if (domainDataTypes.size() > 0) { return super.getDomainForType(environmentContext.getProcessingEnv().getElementUtils().getTypeElement(domainDataTypes.get(0).getCanonicalName()).asType()); } } return super.getDomainForType(type); }
TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(element.getCanonicalName().toString());
@Override final protected int processElement(MutableDeclaredType el, RoundEnvironment roundEnv) { TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(el.getCanonicalName()); boolean alreadyExists = processingEnv.getElementUtils().getTypeElement(outputClass.getCanonicalName()) != null; if (!checkPreconditions(context, alreadyExists)) { if (alreadyExists) { processingEnv.getMessager().printMessage(Kind.NOTE, "[INFO] File " + outputClass.getCanonicalName() + " already exists.", typeElement); processingEnv.getMessager().printMessage(Kind.NOTE, "[INFO] Skipping file " + outputClass.getCanonicalName() + " processing.", typeElement); continue;
public DomainDataInterfaceType(MutableDeclaredType dataDefinition, MutableProcessingEnvironment processingEnv) { super(dataDefinition, processingEnv); Element element = processingEnv.getElementUtils().getTypeElement(dataDefinition.getCanonicalName()); if (getBaseObjects().size() > 1) { processingEnv.getMessager().printMessage(Kind.ERROR, "Multiple base objects interfaces are defined in " + domainDataType + ". You should define only one base object interface!", domainDataType.asElement()); } List<MutableDeclaredType> interfaces = getDataInterfaces(); if (interfaces.size() == 0) { if (new PersistentObjectAccessor(element, processingEnv).isEntity()) { MutableDeclaredType dmainObjectMutableType = processingEnv.getTypeUtils().toMutableType(IMutableDomainObject.class.getName()); interfaces.add(dmainObjectMutableType); } else { interfaces.add(processingEnv.getTypeUtils().toMutableType(Serializable.class)); } } changePackage(dataDefinition.getPackageName() + "." + LocationType.SERVER.getName() + "." + LayerType.MODEL.getName() + "." + ImplementationType.DATA.getName()); setInterfaces(interfaces); setKind(MutableTypeKind.INTERFACE); setDataTypeVariables(); }
TypeElement typeElement = elements.getTypeElement(mutableDeclaredType.getCanonicalName());
return ((MutableDeclaredType)type1).getCanonicalName().equals(((MutableDeclaredType)type2).getCanonicalName());
private MutableTypeMirror findSubtypesForWildcards(MutableTypeMirror type, ExecutableElement ownerMethod) { if (type == null) { return null; } switch (type.getKind()) { case CLASS: case INTERFACE: MutableDeclaredType clone = ((MutableDeclaredType)type).clone(); List<? extends MutableTypeVariable> typeVariables = clone.getTypeVariables(); clone.setTypeVariables(getSubtypesForWildcards((MutableDeclaredType)processingEnv.getTypeUtils().toMutableType(processingEnv.getElementUtils().getTypeElement(((MutableDeclaredType)type).getCanonicalName())), typeVariables, ownerMethod).toArray(new MutableTypeVariable[] {})); return clone; case TYPEVAR: if (((MutableTypeVariable)type).getVariable() != null && ((MutableTypeVariable)type).getVariable() == MutableWildcardType.WILDCARD_NAME) { return getBoundType(((MutableTypeVariable)type).clone(), ownerMethod); } default: return type; } }