本文整理匯總了Java中com.squareup.javapoet.ClassName.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassName.get方法的具體用法?Java ClassName.get怎麽用?Java ClassName.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.squareup.javapoet.ClassName
的用法示例。
在下文中一共展示了ClassName.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeBinding
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private void writeBinding(String targetClassName, Set<Element> annotationFields)
throws IOException {
String packageName = null;
int lastDot = targetClassName.lastIndexOf('.');
if (lastDot > 0) {
packageName = targetClassName.substring(0, lastDot);
}
String targetSimpleClassName = targetClassName.substring(lastDot + 1);
String bindingClassName = targetClassName + "_PrefBinding";
String bindingSimpleClassName = bindingClassName.substring(lastDot + 1);
ClassName targetClass = ClassName.get(packageName, targetSimpleClassName);
TypeSpec binding = TypeSpec.classBuilder(bindingSimpleClassName)
.addModifiers(Modifier.PUBLIC)
.addMethod(buildConstructor(targetClass, annotationFields))
.build();
JavaFile javaFile = JavaFile.builder(packageName, binding).build();
javaFile.writeTo(processingEnv.getFiler());
}
示例2: staticMethodImport
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
/**
* A helper implementation to create a {@link StaticImport} from a {@link Class}
* @param clz the class to import
* @param members the members from that class to import, if none then * is assumed
* @return an anonymous implementation of {@link StaticImport}
*/
static StaticImport staticMethodImport(Class<?> clz, String...members) {
return new StaticImport() {
@Override
public ClassName className() {
return ClassName.get(clz);
}
@Override
public Iterable<String> memberNames() {
if (members.length > 0) {
return Arrays.asList(members);
}
return Collections.singletonList("*");
}
};
}
示例3: RequestManagerGenerator
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
RequestManagerGenerator(ProcessingEnvironment processingEnv, ProcessorUtil processorUtil) {
this.processingEnv = processingEnv;
this.processorUtil = processorUtil;
Elements elementUtils = processingEnv.getElementUtils();
requestManagerType = elementUtils.getTypeElement(REQUEST_MANAGER_QUALIFIED_NAME);
requestManagerClassName = ClassName.get(requestManagerType);
lifecycleType = elementUtils.getTypeElement(LIFECYCLE_QUALIFIED_NAME);
requestManagerTreeNodeType =
elementUtils.getTypeElement(REQUEST_MANAGER_TREE_NODE_QUALIFIED_NAME);
requestBuilderType =
elementUtils.getTypeElement(RequestBuilderGenerator.REQUEST_BUILDER_QUALIFIED_NAME);
glideType = elementUtils.getTypeElement(GLIDE_QUALIFIED_NAME);
}
示例4: generateConstructor
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private MethodSpec generateConstructor(ClassName appGlideModule,
Set<String> libraryGlideModuleClassNames, Set<String> excludedGlideModuleClassNames) {
MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder();
constructorBuilder.addStatement("appGlideModule = new $T()", appGlideModule);
ClassName androidLogName = ClassName.get("android.util", "Log");
// Add some log lines to indicate to developers which modules where discovered.
constructorBuilder.beginControlFlow("if ($T.isLoggable($S, $T.DEBUG))",
androidLogName, GLIDE_LOG_TAG, androidLogName);
constructorBuilder.addStatement("$T.d($S, $S)", androidLogName, GLIDE_LOG_TAG,
"Discovered AppGlideModule from annotation: " + appGlideModule);
// Excluded GlideModule classes from the manifest are logged in Glide's singleton.
for (String glideModule : libraryGlideModuleClassNames) {
ClassName moduleClassName = ClassName.bestGuess(glideModule);
if (excludedGlideModuleClassNames.contains(glideModule)) {
constructorBuilder.addStatement("$T.d($S, $S)", androidLogName, GLIDE_LOG_TAG,
"AppGlideModule excludes LibraryGlideModule from annotation: " + moduleClassName);
} else {
constructorBuilder.addStatement("$T.d($S, $S)", androidLogName, GLIDE_LOG_TAG,
"Discovered LibraryGlideModule from annotation: " + moduleClassName);
}
}
constructorBuilder.endControlFlow();
return constructorBuilder.build();
}
示例5: builder
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private MethodSpec builder() {
ClassName builderClass = ClassName.get(clientPackageName, model.getMetadata().getAsyncBuilder());
ClassName builderInterface = ClassName.get(clientPackageName, model.getMetadata().getAsyncBuilderInterface());
return MethodSpec.methodBuilder("builder")
.returns(builderInterface)
.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
.addJavadoc("Create a builder that can be used to configure and create a {@link $T}.", className)
.addStatement("return new $T()", builderClass)
.build();
}
示例6: ElementDescription
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
public ElementDescription(VariableElement field) {
this.field = field;
key = field.getSimpleName().toString();
Key keyAno = field.getAnnotation(Key.class);
if(keyAno != null) {
String annoValue = keyAno.value();
if(annoValue != null && !"".equals(annoValue)) {
key = annoValue;
}
}
code = field.getAnnotation(Code.class);
fieldType = ClassName.get(field.asType());
fieldName = field.getSimpleName().toString();
}
示例7: BuilderGenerator
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
public BuilderGenerator(TypeElement activity, TypeElement targetActivity,
PackageElement targetPackage,
List<ParameterWriter> parameterList,
List<ResultModel> resultList, TypeElement baseActivityBuilder,
TypeSpec consumer) {
super(activity, targetActivity, targetPackage);
this.parameterList = parameterList;
this.resultList = resultList;
this.baseActivityBuilder = baseActivityBuilder;
builderClass = ClassName.get(targetPackage.getQualifiedName().toString(),
targetActivity.getSimpleName() + "Builder");
builderWithParameter = ParameterizedTypeName.get(builderClass, TypeVariableName.get("A"));
this.consumer = consumer;
}
示例8: generateObjectSetter
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private MethodSpec generateObjectSetter() {
ClassName converterClazz = ClassName.get(keyField.converterPackage, keyField.converter);
return MethodSpec.methodBuilder(getSetterPrefixName())
.addModifiers(PUBLIC)
.addParameter(keyField.typeName, keyField.keyName.toLowerCase())
.addStatement("$T $N = new $T()", converterClazz, INSTANCE_CONVERTER, converterClazz)
.addStatement(getSetterStatement(), preference, EDIT_METHOD, keyField.keyName, INSTANCE_CONVERTER + ".convertObject(" + keyField.keyName.toLowerCase() + ")", APPLY_METHOD)
.build();
}
示例9: visitClassDef
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
@Override public void visitClassDef(JCTree.JCClassDecl jcClassDecl) {
for (JCTree tree : jcClassDecl.defs) {
if (tree instanceof ClassTree) {
ClassTree classTree = (ClassTree) tree;
String className = classTree.getSimpleName().toString();
if (SUPPORTED_TYPES.contains(className)) {
ClassName rClassName = ClassName.get(rPackageName, "R", className);
VarScanner scanner = new VarScanner(ids, rClassName, respectivePackageName);
((JCTree) classTree).accept(scanner);
}
}
}
}
示例10: initProtocolFactory
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
@Override
public MethodSpec initProtocolFactory(IntermediateModel model) {
String exceptionPath = model.getSdkModeledExceptionBaseFqcn()
.substring(0, model.getSdkModeledExceptionBaseFqcn().lastIndexOf("."));
ClassName baseException = ClassName.get(exceptionPath, model.getSdkModeledExceptionBaseClassName());
ClassName protocolFactory = poetExtensions.getClientClass(model.getMetadata().getProtocolFactory());
MethodSpec.Builder methodSpec = MethodSpec.methodBuilder("init")
.returns(protocolFactory)
.addModifiers(Modifier.PRIVATE)
.addCode(
"return new $T(new $T()\n" +
".withProtocolVersion($S)\n" +
".withSupportsCbor($L)\n" +
".withSupportsIon($L)" +
".withBaseServiceExceptionClass($L.class)",
SdkJsonProtocolFactory.class,
JsonClientMetadata.class,
model.getMetadata().getJsonVersion(),
model.getMetadata().isCborProtocol(),
model.getMetadata().isIonProtocol(), baseException);
if (model.getMetadata().getContentType() != null) {
methodSpec.addCode(".withContentTypeOverride($S)", model.getMetadata().getContentType());
}
errorUnmarshallers(model).forEach(methodSpec::addCode);
methodSpec.addCode(");");
return methodSpec.build();
}
示例11: constructorWithAdvancedConfiguration
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private MethodSpec constructorWithAdvancedConfiguration() {
ClassName advancedConfiguration = ClassName.get(basePackage,
model.getCustomizationConfig().getServiceSpecificClientConfigClass());
return MethodSpec.constructorBuilder()
.addModifiers(Modifier.PROTECTED)
.addParameter(SyncClientConfiguration.class, "clientConfiguration")
.addParameter(advancedConfiguration, "serviceConfiguration")
.addStatement("this.clientHandler = new $T(clientConfiguration, serviceConfiguration)",
protocolSpec.getClientHandlerClass())
.addStatement("this.$N = init()", protocolSpec.protocolFactory(model).name)
.addStatement("this.clientConfiguration = clientConfiguration")
.build();
}
示例12: StitchGenerator
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private StitchGenerator(TypeName targetTypeName, ClassName generatingClassName,
ImmutableList<MethodThreadStitching> methodThreadStitchings) {
this.mTargetTypeName = targetTypeName;
this.mGeneratingClassName = generatingClassName;
this.mMethodThreadStitchings = methodThreadStitchings;
mNewThreadExecutor = ClassName.get("amitkma.stitchlib.executors", "NewThreadExecutor");
mUiExecutor = ClassName.get("amitkma.stitchlib.executors", "UiExecutor");
mBackgroundExecutor = ClassName.get("amitkma.stitchlib.executors", "BackgroundExecutor");
}
示例13: beanStyleSetAdvancedConfigurationMethod
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private MethodSpec beanStyleSetAdvancedConfigurationMethod() {
ClassName advancedConfiguration = ClassName.get(basePackage,
model.getCustomizationConfig().getServiceSpecificClientConfigClass());
return MethodSpec.methodBuilder("setAdvancedConfiguration")
.addModifiers(Modifier.PUBLIC)
.addParameter(advancedConfiguration, "advancedConfiguration")
.addStatement("advancedConfiguration(advancedConfiguration)")
.build();
}
示例14: StoreDefinition
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private StoreDefinition(@NonNull ProcessingContext context, @NonNull TypeElement element) {
this.context = context;
this.element = element;
interfaceName = ClassName.get(element);
storeClassName = ClassName.get(interfaceName.packageName(), interfaceName.simpleName() + "_Store");
store = element.getAnnotation(Store.class);
}
示例15: getStubClassName
import com.squareup.javapoet.ClassName; //導入方法依賴的package包/類
private ClassName getStubClassName() {
return ClassName.get(getRemoterInterfacePackageName(), getRemoterInterfaceClassName() + STUB_SUFFIX);
}