当前位置: 首页>>代码示例>>Java>>正文


Java TypeElement.toString方法代码示例

本文整理汇总了Java中javax.lang.model.element.TypeElement.toString方法的典型用法代码示例。如果您正苦于以下问题:Java TypeElement.toString方法的具体用法?Java TypeElement.toString怎么用?Java TypeElement.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.element.TypeElement的用法示例。


在下文中一共展示了TypeElement.toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClassEntity

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * @param elementUtils
 * @param typeUtils
 * @param element      current anntated class
 */
public ClassEntity(Elements elementUtils, Types typeUtils, TypeElement element) {
    elementWeakCache = new WeakReference<TypeElement>(element);
    this.classPackageName = elementUtils.getPackageOf(element).getQualifiedName().toString();
    this.modifierSet = element.getModifiers();
    this.className = element.toString();
    annotationMirrors = element.getAnnotationMirrors();
    this.classSimpleName = element.getSimpleName();
    this.classQualifiedName = element.getQualifiedName();
    if ("java.lang.Object".equals(element.getSuperclass().toString())){
        this.superclass = null;
    }else{
        this.superclass = element.getSuperclass().toString();
    }
    List<? extends TypeMirror> interfaces = element.getInterfaces();

    for (TypeMirror anInterface : interfaces){
        this.interfaces.add(typeUtils.asElement(anInterface).toString());
    }
}
 
开发者ID:simplezhli,项目名称:RxPay,代码行数:25,代码来源:ClassEntity.java

示例2: isAPIClass

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean isAPIClass(TypeElement clazz) {
    String nameS = /*!!!!*/clazz.toString();
    
    for (String s : API_PACKAGES) {
        if (nameS.startsWith(s))
            return true;
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:APIIsSelfContainedTest.java

示例3: checkExclusion

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean checkExclusion(TypeElement element) {
    final String typeName=element.toString();
    boolean r= this.processingInfo.getTsModel().getModuleInfo().getExcludes().stream().anyMatch(
            x -> x.matcher(typeName).find()
    );
    if (r) LOG.fine(() -> "TSAP exclusion " + element);
    return r;
}
 
开发者ID:dzuvic,项目名称:jtsgen,代码行数:9,代码来源:TypeScriptAnnotationProcessor.java

示例4: checkClassVisibility

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private static void checkClassVisibility(Elements eles, TypeElement target, String fromPkg) {
    Set<Modifier> targetMods = target.getModifiers();
    if (!isNestedClass(target)) {
        simpleVisibility(target.getModifiers(), eles.getPackageOf(target), fromPkg, target);
    } else {
        Element surround = target.getEnclosingElement();

        if (surround.getKind() != CLASS
                && surround.getKind() != INTERFACE
                // Not sure if that is allowed, but we include it anyways.
                && surround.getKind() != ENUM) {
            throw new IllegalStateException(
                    target.toString() + " is not nested? " + surround.toString());
        }

        TypeElement enclosingType = (TypeElement) surround;

        // The surrounding class must be visible for us to see the nested class
        if (!isElementVisibleFrom(eles, enclosingType, fromPkg)) {
            throw new EasyPluginException(enclosingType.toString()
                    + " is not visible from output package; need for access to " + target.toString());
        }
        // Nested class must be static since we don't have an enclosing instance
        if (!targetMods.contains(Modifier.STATIC)) {
            throw new EasyPluginException(target.toString() + " must be static.");
        }

        simpleVisibility(target.getModifiers(), eles.getPackageOf(target), fromPkg, target);
    }
}
 
开发者ID:c0d3d,项目名称:easy-plugins,代码行数:31,代码来源:Util.java

示例5: generate

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public boolean generate(VariableElement variableElement, List<ClassGeneratingParams> classGeneratingParamsList) {
	final Element enclosingElement = variableElement.getEnclosingElement();

	if (!(enclosingElement instanceof TypeElement)) {
		throw new RuntimeException("Only class fields could be annotated as @InjectPresenter: " + variableElement + " at " + enclosingElement);
	}

	if (mPresentersContainers.contains(enclosingElement)) {
		return false;
	}

	TypeElement presentersContainer = (TypeElement) enclosingElement;

	mPresentersContainers.add(presentersContainer);

	String fullClassName = Util.getFullClassName(presentersContainer);

	ClassGeneratingParams classGeneratingParams = new ClassGeneratingParams();
	classGeneratingParams.setName(fullClassName + MvpProcessor.PRESENTER_BINDER_SUFFIX);

	String parentClassName = presentersContainer.toString();

	final String viewClassName = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);

	String builder = "package " + fullClassName.substring(0, fullClassName.lastIndexOf(".")) + ";\n" +
	                 "\n" +
	                 "import java.util.ArrayList;\n" +
	                 "import java.util.List;\n" +
	                 "\n" +
	                 "import com.arellomobile.mvp.PresenterBinder;\n" +
	                 "import com.arellomobile.mvp.presenter.PresenterField;\n" +
	                 "import com.arellomobile.mvp.MvpPresenter;\n" +
	                 "import com.arellomobile.mvp.presenter.PresenterType;\n" +
	                 "\n" +
	                 "public class " + viewClassName + MvpProcessor.PRESENTER_BINDER_SUFFIX + " extends PresenterBinder<" + parentClassName + "> {\n";

	List<Field> fields = collectFields(presentersContainer);

	List<PresenterProvider> presenterProviders = collectPresenterProviders(presentersContainer);

	List<TagProvider> tagProviders = collectTagProviders(presentersContainer);

	bindProvidersToFields(fields, presenterProviders);

	bindTagProvidersToFields(fields, tagProviders);

	for (Field field : fields) {
		builder = generatePresenterBinderClass(builder, parentClassName, field);
	}

	builder = generateGetPresentersMethod(builder, fields, parentClassName);

	builder += "}\n";

	classGeneratingParams.setBody(builder);
	classGeneratingParamsList.add(classGeneratingParams);

	return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:60,代码来源:PresenterBinderClassGenerator.java

示例6: generate

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public boolean generate(TypeElement typeElement, List<ClassGeneratingParams> classGeneratingParamsList) {
	String fullPresenterClassName = typeElement.toString();

	mPresenterClassNames.add(fullPresenterClassName);

	final String presenterClassName = fullPresenterClassName.substring(fullPresenterClassName.lastIndexOf(".") + 1);

	String viewState = getViewStateClassFromAnnotationParams(typeElement);
	if (viewState == null) {
		String view = getViewClassFromAnnotationParams(typeElement);
		if (view == null) {
			view = getViewClassFromGeneric(typeElement);
		}

		if (view != null) {
			// Remove generic from view class name
			if (view.contains("<")) {
				view = view.substring(0, view.indexOf("<"));
			}

			TypeElement viewTypeElement = MvpCompiler.getElementUtils().getTypeElement(view);
			if (viewTypeElement == null) {
				throw new IllegalArgumentException("View \"" + view + "\" for " + typeElement + " cannot be found");
			}

			mUsedViews.add(viewTypeElement);
			viewState = Util.getFullClassName(viewTypeElement) + MvpProcessor.VIEW_STATE_SUFFIX;
		}
	}

	String builder = "package " + fullPresenterClassName.substring(0, fullPresenterClassName.lastIndexOf(".")) + ";\n" +
	                 "\n" +
	                 "import com.arellomobile.mvp.ViewStateProvider;\n" +
	                 "import com.arellomobile.mvp.MvpView;\n" +
	                 "import com.arellomobile.mvp.viewstate.MvpViewState;\n" +
	                 "\npublic class " + presenterClassName + MvpProcessor.VIEW_STATE_PROVIDER_SUFFIX + " extends ViewStateProvider {\n" +
	                 "\t\n" +
	                 "\[email protected]\n" +
	                 "\tpublic MvpViewState<? extends MvpView> getViewState() {\n";
	if (viewState == null) {
		builder += "\t\tthrow new RuntimeException(" + fullPresenterClassName + " should has view\");\n";
	} else {
		builder += "\t\treturn new " + viewState + "();\n";
	}
	builder += "\t}\n" +
	           "}";

	ClassGeneratingParams classGeneratingParams = new ClassGeneratingParams();
	classGeneratingParams.setName(fullPresenterClassName + MvpProcessor.VIEW_STATE_PROVIDER_SUFFIX);
	classGeneratingParams.setBody(builder);
	classGeneratingParamsList.add(classGeneratingParams);

	return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:56,代码来源:ViewStateProviderClassGenerator.java

示例7: HandleImplGenerator

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public HandleImplGenerator(TypeElement element, String classNameSuffix, String superinterface) {
    super(element, classNameSuffix);
    this.mSuperinterface = superinterface;
    this.mSharedPreferencesName = element.toString();
}
 
开发者ID:xuehuayous,项目名称:Hannibai,代码行数:6,代码来源:HandleImplGenerator.java

示例8: checkConcreteType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
static void checkConcreteType(TypeElement e) {
    Set<Modifier> mods = e.getModifiers();
    if (mods.contains(Modifier.ABSTRACT) || e.getKind().isInterface()) {
        throw new EasyPluginException(e.toString() + " must be concrete to use as a service.");
    }
}
 
开发者ID:c0d3d,项目名称:easy-plugins,代码行数:7,代码来源:Util.java


注:本文中的javax.lang.model.element.TypeElement.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。