public static String getPackageName(Elements elementUtils, Types typeUtils, TypeMirror type) {
		TypeVisitor<DeclaredType, Object> tv = new SimpleTypeVisitor6<DeclaredType, Object>() {

			@Override
			public DeclaredType visitDeclared(DeclaredType t, Object p) {
				return t;
			}
		};
		DeclaredType dt = type.accept(tv, null);
		if (dt != null) {
			ElementVisitor<TypeElement, Object> ev =
					new SimpleElementVisitor6<TypeElement, Object>() {

						@Override
						public TypeElement visitType(TypeElement e, Object p) {
							return e;
						}
					};
			TypeElement el = typeUtils.asElement(dt).accept(ev, null);
			if (el != null && el.getNestingKind() != NestingKind.TOP_LEVEL) {
				return AptUtil.getPackageName(elementUtils, el);
			}
		}
		return AptUtil.getPackageNameSub(type);
	}
public static String getPackageName ( Elements elementUtils , Types typeUtils , TypeMirror type ) { TypeVisitor < DeclaredType , Object > tv = new SimpleTypeVisitor6 < DeclaredType , Object > ( ) { @ Override public DeclaredType visitDeclared ( DeclaredType t , Object p ) { return t ; } } ; DeclaredType dt = type . accept ( tv , null ) ; if ( dt != null ) { ElementVisitor < TypeElement , Object > ev = new SimpleElementVisitor6 < TypeElement , Object > ( ) { @ Override public TypeElement visitType ( TypeElement e , Object p ) { return e ; } } ; TypeElement el = typeUtils . asElement ( dt ) . accept ( ev , null ) ; if ( el != null && el . getNestingKind ( ) != NestingKind . TOP_LEVEL ) { return AptUtil . getPackageName ( elementUtils , el ) ; } } return AptUtil . getPackageNameSub ( type ) ; }
Returns the package name of the given {@link TypeMirror}.
@param elementUtils
@param typeUtils
@param type
@return the package name
@author backpaper0
@author vvakame