Java 8 PackageElement - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PackageElement class.

This code example shows how to use the following methods:getQualifiedName
This code example shows how to use the following methods:getQualifiedName, isUnnamed
   * 
   * @throws IOException 
   */ 
  public static String getPackageName(Elements elementUtils, TypeElement type) throws IOException {
    PackageElement pkg = elementUtils.getPackageOf(type);
    if (!pkg.isUnnamed()) {
      return pkg.getQualifiedName().toString();
    } else { 
      return ""; // Default package 
    } 
  } 
} 
4
CodeRank
This code example shows how to use the following methods:getQualifiedName
        writer.endType();
        writer.close();
    } 
 
    private void emitClassHeader(PackageElement packageElement, TypeElement activityType, JavaWriter writer) throws IOException {
        writer.emitPackage(packageElement.getQualifiedName().toString());
 
        if (isFragmentActivity(activityType)) {
            writer.emitImports("android.support.v4.app.Fragment");
        } else { 
            writer.emitImports("android.app.Fragment");
        } 
        writer.emitImports("android.app.Activity");
        writer.emitEmptyLine();
    } 
 
    private TypeElement findAndroidActivitySuperType(TypeElement activityType) {
        final String typeName = activityType.getQualifiedName().toString();
        if (typeName.equals("java.lang.Object")) {
            return null; 
3
CodeRank
This code example shows how to use the following methods:getQualifiedName, isUnnamed
      return false; 
    } 
    // TODO Check if el is an accessible member for subclasses AND builderM actually is a subclass 
    PackageElement fieldPackage = elements.getPackageOf(el);
    String builderPackge = builderM.getType().getPackageName();
    if (fieldPackage.isUnnamed()) {
      return builderPackge == null;
    } else { 
      return fieldPackage.getQualifiedName().toString().equals(builderPackge);
    } 
  } 
 
  /** 
   * Returns true if the given element is marked with a 'static' modifier. 
   *  
   * @param el the element 
   * @return true if the given element is marked with a 'static' modifier 
   */ 
  public boolean isStatic(Element el) {
    return el.getModifiers().contains(STATIC);
3
CodeRank
This code example shows how to use the following methods:getQualifiedName, isUnnamed
    return types.isAssignable(typeMirror, elements.getTypeElement(type).asType());
  } 
 
  public String getPackageName(TypeElement type) {
    PackageElement pkg = elements.getPackageOf(type);
    if (!pkg.isUnnamed()) {
      return pkg.getQualifiedName().toString();
    } else { 
      return ""; // Default package 
    } 
  } 
} 
4
CodeRank
This code example shows how to use the following methods:getQualifiedName
		return getPackageName() + "." + getClassName(); 
	} 
 
	protected String getPackageName() {
		PackageElement pkgEl = (PackageElement) this.typeElement.getEnclosingElement();
		return pkgEl.getQualifiedName().toString();
	} 
 
	protected String getClassName() {
		return this.typeElement.getSimpleName().toString();
	} 
 
	protected List<String> inspectInterfaces() {
		// get list of interfaces 
		List<String> iNames = new ArrayList<String>();
		List<? extends TypeMirror> interfaces = this.typeElement.getInterfaces();
		for (TypeMirror i : interfaces) {
			String iName = i.toString();
			iNames.add(iName);
		} 
3
CodeRank
This code example shows how to use the following methods:getSimpleName
	} 
 
	@Override 
	public R visitPackage(PackageElement e, P p)
	{ 
		log("visitPackage(PackageElement e=[%s], P p=[%s])", e.getSimpleName(), p);
		if (next != null)
			return next.visitPackage(e, p);
		return null; 
	} 
 
	@Override 
	public R visitType(TypeElement e, P p)
	{ 
		log("visitType(TypeElement e=[%s], P p=[%s])", e.getSimpleName(), p);
		if (next != null)
			return next.visitType(e, p);
		return null; 
	} 
 
4
CodeRank
This code example shows how to use the following methods:getAnnotation
 
	private void storeClassFromPackage(PackageElement packageElement, TypeElement rootElement) throws IOException {
		if (indexedPackages.contains(packageElement.getQualifiedName().toString())) {
			putElement(packageMap, packageElement, rootElement);
		} else if (annotationDriven) {
			IndexSubclasses indexSubclasses = packageElement.getAnnotation(IndexSubclasses.class);
			if (indexSubclasses != null) {
				String simpleName = getShortName(rootElement);
				if (simpleName != null) {
					putElement(packageMap, packageElement, simpleName);
					if (indexSubclasses.storeJavadoc()) {
						storeJavadoc(rootElement);
					} 
				} 
			} 
		} 
	} 
 
	private <K> void putElement(Map<K, Set<String>> map, K keyElement, TypeElement valueElement) {
		final String fullName = getFullName(valueElement);
3
CodeRank
See Code Examples for Java 8 PackageElement Methods: