com.moparisthebest.mirror.declaration.ConvertPackageDeclaration Maven / Gradle / Ivy
/*
* aptIn16 - Apt implementation with Java 6 annotation processors.
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published y
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.moparisthebest.mirror.declaration;
import com.sun.mirror.declaration.*;
import com.moparisthebest.mirror.log.Debug;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.PackageElement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class ConvertPackageDeclaration extends ConvertDeclaration implements com.sun.mirror.declaration.PackageDeclaration {
protected final PackageElement internalPackageElement;
protected ConvertPackageDeclaration(PackageElement internalPackageElement) {
super(internalPackageElement);
this.internalPackageElement = internalPackageElement;
}
@Override
public String getQualifiedName() {
return internalPackageElement.getQualifiedName().toString();
}
private Collection getTypeDeclarations(Class type, ElementKind kind) {
// ElementFilter.typesIn(internalPackageElement.getEnclosedElements())
// only filters on types in general, we need finer granularity
List ret = new ArrayList();
for (Element e : internalPackageElement.getEnclosedElements())
if (e.getKind() == kind)
ret.add(convert(e, type));
return ret;
}
@Override
public Collection getClasses() {
Debug.implemented("Collection");
return getTypeDeclarations(ClassDeclaration.class, ElementKind.CLASS);
}
@Override
public Collection getEnums() {
Debug.implemented("Collection");
return getTypeDeclarations(EnumDeclaration.class, ElementKind.ENUM);
}
@Override
public Collection getInterfaces() {
Debug.implemented("Collection");
return getTypeDeclarations(InterfaceDeclaration.class, ElementKind.INTERFACE);
}
@Override
public Collection getAnnotationTypes() {
Debug.implemented("Collection");
return getTypeDeclarations(AnnotationTypeDeclaration.class, ElementKind.ANNOTATION_TYPE);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy