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


Java ClassName.get方法代码示例

本文整理汇总了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());
}
 
开发者ID:quangctkm9207,项目名称:prefpin,代码行数:24,代码来源:PrefPinProcessor.java

示例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("*");
        }
    };
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:23,代码来源:StaticImport.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RequestManagerGenerator.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:AppModuleGenerator.java

示例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();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:11,代码来源:AsyncClientInterface.java

示例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();
}
 
开发者ID:foreveruseful,项目名称:smartkey,代码行数:15,代码来源:ElementDescription.java

示例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;
}
 
开发者ID:douo,项目名称:ActivityBuilder,代码行数:16,代码来源:BuilderGenerator.java

示例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();
}
 
开发者ID:skydoves,项目名称:PreferenceRoom,代码行数:10,代码来源:PreferenceFieldMethodGenerator.java

示例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);
      }
    }
  }
}
 
开发者ID:qq542391099,项目名称:butterknife-parent,代码行数:14,代码来源:ButterKnifeProcessor.java

示例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();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:35,代码来源:JsonProtocolSpec.java

示例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();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:14,代码来源:SyncClientClass.java

示例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");
}
 
开发者ID:amitkma,项目名称:Stitch,代码行数:11,代码来源:StitchGenerator.java

示例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();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:10,代码来源:BaseClientBuilderClass.java

示例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);
}
 
开发者ID:hisaichi5518,项目名称:konohana,代码行数:10,代码来源:StoreDefinition.java

示例15: getStubClassName

import com.squareup.javapoet.ClassName; //导入方法依赖的package包/类
private ClassName getStubClassName() {
    return ClassName.get(getRemoterInterfacePackageName(), getRemoterInterfaceClassName() + STUB_SUFFIX);
}
 
开发者ID:josesamuel,项目名称:remoter,代码行数:4,代码来源:ClassBuilder.java


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