當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。