• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WildcardTypeName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.squareup.javapoet.WildcardTypeName的典型用法代码示例。如果您正苦于以下问题:Java WildcardTypeName类的具体用法?Java WildcardTypeName怎么用?Java WildcardTypeName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WildcardTypeName类属于com.squareup.javapoet包,在下文中一共展示了WildcardTypeName类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: bestGuess

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private static TypeName bestGuess(String type) {
  switch (type) {
    case "void": return TypeName.VOID;
    case "boolean": return TypeName.BOOLEAN;
    case "byte": return TypeName.BYTE;
    case "char": return TypeName.CHAR;
    case "double": return TypeName.DOUBLE;
    case "float": return TypeName.FLOAT;
    case "int": return TypeName.INT;
    case "long": return TypeName.LONG;
    case "short": return TypeName.SHORT;
    default:
      int left = type.indexOf('<');
      if (left != -1) {
        ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
        List<TypeName> typeArguments = new ArrayList<>();
        do {
          typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
          left = type.indexOf('<', left + 1);
        } while (left != -1);
        return ParameterizedTypeName.get(typeClassName,
            typeArguments.toArray(new TypeName[typeArguments.size()]));
      }
      return ClassName.bestGuess(type);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:BindingSet.java


示例2: generateConstructors

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private List<MethodSpec> generateConstructors() {
  ParameterizedTypeName classOfTranscodeType =
      ParameterizedTypeName.get(ClassName.get(Class.class), transcodeTypeName);

  TypeName wildcardOfObject = WildcardTypeName.subtypeOf(Object.class);
  ParameterizedTypeName requestBuilderOfWildcardOfObject =
      ParameterizedTypeName.get(ClassName.get(requestBuilderType), wildcardOfObject);

  MethodSpec firstConstructor =
      MethodSpec.constructorBuilder()
          .addParameter(classOfTranscodeType, "transcodeClass")
          .addParameter(requestBuilderOfWildcardOfObject, "other")
      .addStatement("super($N, $N)", "transcodeClass", "other")
      .build();

  ClassName glide = ClassName.get("com.bumptech.glide", "Glide");
  ClassName requestManager = ClassName.get("com.bumptech.glide", "RequestManager");
  MethodSpec secondConstructor =
      MethodSpec.constructorBuilder()
          .addParameter(glide, "glide")
          .addParameter(requestManager, "requestManager")
          .addParameter(classOfTranscodeType, "transcodeClass")
          .addStatement("super($N, $N ,$N)", "glide", "requestManager", "transcodeClass")
          .build();
  return ImmutableList.of(firstConstructor, secondConstructor);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:RequestBuilderGenerator.java


示例3: createIsJsObject

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec createIsJsObject() {
    CodeBlock.Builder builder = CodeBlock.builder();
    builder.addStatement("$1T jsType = type.getAnnotation($1T.class)", ClassNames.JSINTEROP_JSTYPE);
    Stream.of(
            "jsType == null",
            "!jsType.isNative()",
            "!JsPackage.GLOBAL.equals(jsType.namespace())",
            "!\"Object\".equals(jsType.name())")
        .forEachOrdered(statement -> builder
                .beginControlFlow("if (" + statement + ")")
                    .addStatement("return false")
                .endControlFlow());
    builder.addStatement("return true");

    return MethodSpec.methodBuilder("isJsObject")
            .addModifiers(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)
            .addAnnotation(ClassNames.GWT_INCOMPATIBLE)
            .addParameter(ParameterizedTypeName.get(ClassName.get(Class.class), WildcardTypeName.subtypeOf(Object.class)), "type")
            .returns(Boolean.TYPE)
            .addCode(builder.build())
            .build();
}
 
开发者ID:codegen-io,项目名称:jso-builder,代码行数:23,代码来源:SerializerGenerator.java


示例4: builderCopyMethodForList

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec builderCopyMethodForList() {
    TypeName keyType = typeProvider.getTypeNameForSimpleType(memberModel.getMapModel().getKeyModel()
                                                                        .getVariable().getVariableType());
    ClassName valueParameter = poetExtensions.getModelClass(memberModel.getMapModel().getValueModel().getC2jShape());
    ClassName builderForParameter = valueParameter.nestedClass("Builder");
    TypeName parameterType =
        ParameterizedTypeName.get(ClassName.get(Map.class), keyType, WildcardTypeName.subtypeOf(builderForParameter));

    CodeBlock code =
        CodeBlock.builder()
                 .beginControlFlow("if ($N == null)", memberParamName())
                 .addStatement("return null")
                 .endControlFlow()
                 .addStatement("return $N($N.entrySet().stream().collect(toMap($T::getKey, e -> e.getValue().build())))",
                               serviceModelCopiers.copyMethodName(),
                               memberParamName(),
                               Map.Entry.class)
                 .build();

    return MethodSpec.methodBuilder(serviceModelCopiers.builderCopyMethodName())
                     .addModifiers(Modifier.STATIC)
                     .addParameter(parameterType, memberParamName())
                     .returns(typeProvider.fieldType(memberModel))
                     .addCode(code)
                     .build();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:27,代码来源:MemberCopierSpec.java


示例5: builderCopyMethodForMap

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec builderCopyMethodForMap() {
    ClassName listParameter = poetExtensions.getModelClass(memberModel.getListModel().getListMemberModel().getC2jShape());
    ClassName builderForParameter = listParameter.nestedClass("Builder");

    TypeName parameterType =
        ParameterizedTypeName.get(ClassName.get(Collection.class), WildcardTypeName.subtypeOf(builderForParameter));

    CodeBlock code = CodeBlock.builder()
                              .beginControlFlow("if ($N == null)", memberParamName())
                              .addStatement("return null")
                              .endControlFlow()
                              .addStatement("return $N($N.stream().map($T::$N).collect(toList()))",
                                            serviceModelCopiers.copyMethodName(),
                                            memberParamName(),
                                            builderForParameter,
                                            "build")
                              .build();

    return MethodSpec.methodBuilder(serviceModelCopiers.builderCopyMethodName())
                     .addModifiers(Modifier.STATIC)
                     .addParameter(parameterType, memberParamName())
                     .returns(typeProvider.fieldType(memberModel))
                     .addCode(code)
                     .build();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:26,代码来源:MemberCopierSpec.java


示例6: generateConstructor

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private void generateConstructor(TypeSpec.Builder classBuilder) {
    MethodSpec.Builder builder = MethodSpec.constructorBuilder()
            .addModifiers(Modifier.PUBLIC)
            .addParameter(TypeName.get(targetType), PocketBusConst.VAR_TARGET);

    if (parentAdapter != null) {
        builder.addStatement("super($N)", PocketBusConst.VAR_TARGET);
    }

    builder.addStatement("this.$N = new $T($N)", PocketBusConst.VAR_TARGET_REF, getWeakReferenceType(), PocketBusConst.VAR_TARGET)
            .addStatement("$T $N = new $T()", LIST_TYPE, PocketBusConst.VAR_SUBSCRIPTIONS, ParameterizedTypeName.get(ClassName.get(ArrayList.class),
                    ParameterizedTypeName.get(ClassName.get(Subscription.class), WildcardTypeName.subtypeOf(TypeName.OBJECT))));

    if (parentAdapter != null) {
        builder.addStatement("$N.addAll(super.$L())", PocketBusConst.VAR_SUBSCRIPTIONS, PocketBusConst.METHOD_GET_SUBSCRIPTIONS);
    }

    for (SubscriptionMethod method : methods) {
        builder.addStatement("$N.add($N)", PocketBusConst.VAR_SUBSCRIPTIONS, PocketBusConst.VAR_SUBSCRIPTION + method.getIndex());
    }

    builder.addStatement("this.$N = $T.unmodifiableList($N)", PocketBusConst.VAR_SUBSCRIPTIONS, ClassName.get(Collections.class),
            PocketBusConst.VAR_SUBSCRIPTIONS);

    classBuilder.addMethod(builder.build());
}
 
开发者ID:hansenji,项目名称:PocketBus,代码行数:27,代码来源:SubscriptionGenerator.java


示例7: isBindable

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
/**
 * Returns true if the given type can be bound to some type. Note: this should
 * not be used with raw type of generic type.
 */
public static boolean isBindable(TypeName typeName) {
  if (typeName instanceof ParameterizedTypeName) {
    for (TypeName t : ((ParameterizedTypeName) typeName).typeArguments) {
      if (!isBindable(t)) {
        return false;
      }
    }
    return true;
  } else if (typeName instanceof ClassName) {
    return true;
  } else if (typeName instanceof WildcardTypeName) {
    return true;
  } else
    return typeName.isPrimitive();
}
 
开发者ID:google,项目名称:tiger,代码行数:20,代码来源:Utils.java


示例8: generate

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
public void generate() {
    MethodSpec.Builder addHandlerMethod = MethodSpec.methodBuilder("addHandler")
                                                    .addAnnotation(Override.class)
                                                    .addModifiers(Modifier.PUBLIC)
                                                    .addParameter(ParameterizedTypeName.get(ClassName.get(IsPresenter.class),
                                                                                            WildcardTypeName.subtypeOf(Object.class),
                                                                                            WildcardTypeName.subtypeOf(Object.class)),
                                                                  "presenter")
                                                    .returns(ClassName.get(PresenterRegistration.class));
    // TODO implementing addHandler feature ...
//    // List of already created EventHandler used to avoid a second create ...
//    List<ClassNameModel> listOfEventHandlersToCreate = this.createListOfEventHandlersToCreate();
//    listOfEventHandlersToCreate.forEach(handlerClassName -> this.addHandlerToMetaList(loadEventHandlerMethod,
//                                                                                      handlerClassName));




    addHandlerMethod.addStatement("return null");
    typeSpec.addMethod(addHandlerMethod.build());
  }
 
开发者ID:mvp4g,项目名称:mvp4g2,代码行数:22,代码来源:AddPresenterGenerator.java


示例9: appendTypes

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private void appendTypes(TypeSpec.Builder builder) {
  // Field
  TypeName classTypeName = ParameterizedTypeName.get(ClassName.get(Class.class),
      WildcardTypeName.subtypeOf(Resource.class));

  specTypes =
      createMapWithInitializer("types", LinkedHashMap.class, ClassName.get(String.class),
          classTypeName)
          .addModifiers(Modifier.FINAL)
          .build();

  builder.addField(specTypes);

  // Getter
  builder.addMethod(createGetterImpl(specTypes, "getTypes").build());
}
 
开发者ID:contentful,项目名称:vault,代码行数:17,代码来源:SpaceInjection.java


示例10: appendModels

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private void appendModels(TypeSpec.Builder builder) {
  // Field
  TypeName classTypeName = ParameterizedTypeName.get(ClassName.get(Class.class),
      WildcardTypeName.subtypeOf(Object.class));

  TypeName helperTypeName = ParameterizedTypeName.get(ClassName.get(ModelHelper.class),
      WildcardTypeName.subtypeOf(Object.class));

  specModels = createMapWithInitializer("models", LinkedHashMap.class, classTypeName,
      helperTypeName).addModifiers(Modifier.FINAL).build();

  builder.addField(specModels);

  // Getter
  builder.addMethod(createGetterImpl(specModels, "getModels").build());
}
 
开发者ID:contentful,项目名称:vault,代码行数:17,代码来源:SpaceInjection.java


示例11: testAdderAll

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
@Test
public void testAdderAll() throws Exception {
    BuildableRDFSProperty loadCap = getPropertyFromModel("http://example.de/ont#load_capacity");
    assertNotNull(loadCap);

    MethodSpec loadCapSpec = loadCap.buildAdderAll(declaringClass, generationConfig);

    // Test signature:
    assertEquals("addAllMaximumLoadCapacities", loadCapSpec.name);
    assertTrue(loadCapSpec.modifiers.contains(Modifier.PUBLIC));
    assertEquals(1, loadCapSpec.parameters.size());
    ClassName setClass = ClassName.get("java.util", "Set");
    assertEquals(ParameterizedTypeName.get(setClass, WildcardTypeName.subtypeOf(ClassName.get(Float.class))), loadCapSpec.parameters.get(0).type);

    // Test JavaDoc:
    assertNotNull(loadCapSpec.javadoc);
    assertTrue(loadCapSpec.javadoc.toString().startsWith("Ladung in Tonnen"));

    // Test annotation:
    assertEquals(0, loadCapSpec.annotations.size());
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:22,代码来源:RDFSPropertySpecTest.java


示例12: testRemoverAll

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
@Test
public void testRemoverAll() throws Exception {
    BuildableRDFSProperty loadCap = getPropertyFromModel("http://example.de/ont#load_capacity");
    assertNotNull(loadCap);

    MethodSpec loadCapSpec = loadCap.buildRemoverAll(declaringClass, generationConfig);

    // Test signature:
    assertEquals("removeAllMaximumLoadCapacities", loadCapSpec.name);
    assertTrue(loadCapSpec.modifiers.contains(Modifier.PUBLIC));
    assertEquals(1, loadCapSpec.parameters.size());
    ClassName setClass = ClassName.get("java.util", "Set");
    assertEquals(ParameterizedTypeName.get(setClass, WildcardTypeName.subtypeOf(ClassName.get(Float.class))), loadCapSpec.parameters.get(0).type);

    // Test JavaDoc:
    assertNotNull(loadCapSpec.javadoc);
    assertTrue(loadCapSpec.javadoc.toString().startsWith("Ladung in Tonnen"));

    // Test annotation:
    assertEquals(0, loadCapSpec.annotations.size());
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:22,代码来源:RDFSPropertySpecTest.java


示例13: simpleName

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private static String simpleName(TypeName typeName) {
  if (typeName instanceof ClassName) {
    return UPPER_CAMEL.to(LOWER_CAMEL, ((ClassName) typeName).simpleName());
  } else if (typeName instanceof ParameterizedTypeName) {
    ParameterizedTypeName parameterizedTypeName = (ParameterizedTypeName) typeName;
    return UPPER_CAMEL.to(LOWER_CAMEL, parameterizedTypeName.rawType.simpleName())
        + (parameterizedTypeName.typeArguments.isEmpty() ? "" : "__")
        + simpleName(parameterizedTypeName.typeArguments);
  } else if (typeName instanceof ArrayTypeName) {
    return "array__" + simpleName(((ArrayTypeName) typeName).componentType);
  } else if (typeName instanceof WildcardTypeName) {
    WildcardTypeName wildcardTypeName = (WildcardTypeName) typeName;
    return "wildcard__"
        + simpleName(ImmutableList.<TypeName>builder().addAll(wildcardTypeName.lowerBounds)
        .addAll(wildcardTypeName.upperBounds)
        .build());
  } else if (typeName instanceof TypeVariableName) {
    TypeVariableName variable = (TypeVariableName) typeName;
    return variable.name
        + (variable.bounds.isEmpty() ? "" : "__")
        + simpleName(variable.bounds);
  } else {
    return typeName.toString();
  }
}
 
开发者ID:rharter,项目名称:auto-value-gson,代码行数:26,代码来源:AutoValueGsonExtension.java


示例14: createStartServices

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec createStartServices() {
    ClassName memoryServiceConnection = ClassName.get(PACKAGE, "MemoryServiceConnection");

    CodeBlock code = CodeBlock.builder()
            .beginControlFlow("for($T service: $L)", ParameterizedTypeName.get(ClassName.get(Class.class), WildcardTypeName.subtypeOf(Service.class)), FIELD_SERVICES)
            .addStatement("$T intent = new $T(context, service)", Intent.class, Intent.class)
            .addStatement("context.startService(intent)")
            .add("\n")
            .addStatement("$T connection = new $T()", memoryServiceConnection, memoryServiceConnection)
            .addStatement("context.bindService(intent, connection, Context.BIND_AUTO_CREATE)")
            .endControlFlow()
            .build();

    return MethodSpec.methodBuilder("startServices")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .addParameter(ClassName.get(Context.class), "context")
            .addCode(code)
            .build();
}
 
开发者ID:T-Spoon,项目名称:Android-Developer-Toolbelt,代码行数:21,代码来源:ServiceHolderWriter.java


示例15: collectionCollectionSetter

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec collectionCollectionSetter(final Descriptor d, final ExecutableElement field) {
  String fieldName = fieldName(field);
  ClassName collectionType = ClassName.get(Collection.class);
  TypeName itemType = genericArgument(field, 0);
  WildcardTypeName extendedType = subtypeOf(itemType);

  MethodSpec.Builder setter = MethodSpec.methodBuilder(fieldName)
      .addModifiers(PUBLIC)
      .addParameter(ParameterizedTypeName.get(collectionType, extendedType), fieldName)
      .returns(builderType(d));

  collectionNullGuard(setter, field);
  if (shouldEnforceNonNull(field)) {
    setter.beginControlFlow("for ($T item : $N)", itemType, fieldName);
    assertNotNull(setter, "item", fieldName + ": null item");
    setter.endControlFlow();
  }

  setter.addStatement("this.$N = new $T($N)", fieldName, collectionImplType(field), fieldName);
  return setter.addStatement("return this").build();
}
 
开发者ID:danielnorberg,项目名称:auto-matter,代码行数:22,代码来源:AutoMatterProcessor.java


示例16: collectionIterableSetter

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec collectionIterableSetter(final Descriptor d, final ExecutableElement field) {
  String fieldName = fieldName(field);
  ClassName iterableType = ClassName.get(Iterable.class);
  TypeName itemType = genericArgument(field, 0);
  WildcardTypeName extendedType = subtypeOf(itemType);

  MethodSpec.Builder setter = MethodSpec.methodBuilder(fieldName)
      .addModifiers(PUBLIC)
      .addParameter(ParameterizedTypeName.get(iterableType, extendedType), fieldName)
      .returns(builderType(d));

  collectionNullGuard(setter, field);

  ClassName collectionType = ClassName.get(Collection.class);
  setter.beginControlFlow("if ($N instanceof $T)", fieldName, collectionType)
      .addStatement("return $N(($T<$T>) $N)", fieldName, collectionType, extendedType, fieldName)
      .endControlFlow();

  setter.addStatement("return $N($N.iterator())", fieldName, fieldName);
  return setter.build();
}
 
开发者ID:danielnorberg,项目名称:auto-matter,代码行数:22,代码来源:AutoMatterProcessor.java


示例17: collectionIteratorSetter

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec collectionIteratorSetter(final Descriptor d, final ExecutableElement field) {
  String fieldName = fieldName(field);
  ClassName iteratorType = ClassName.get(Iterator.class);
  TypeName itemType = genericArgument(field, 0);
  WildcardTypeName extendedType = subtypeOf(itemType);

  MethodSpec.Builder setter = MethodSpec.methodBuilder(fieldName)
      .addModifiers(PUBLIC)
      .addParameter(ParameterizedTypeName.get(iteratorType, extendedType), fieldName)
      .returns(builderType(d));

  collectionNullGuard(setter, field);

  setter.addStatement("this.$N = new $T()", fieldName, collectionImplType(field))
      .beginControlFlow("while ($N.hasNext())", fieldName)
      .addStatement("$T item = $N.next()", itemType, fieldName);

  if (shouldEnforceNonNull(field)) {
    assertNotNull(setter, "item", fieldName + ": null item");
  }

  setter.addStatement("this.$N.add(item)", fieldName)
      .endControlFlow();

  return setter.addStatement("return this").build();
}
 
开发者ID:danielnorberg,项目名称:auto-matter,代码行数:27,代码来源:AutoMatterProcessor.java


示例18: generateGetExcludedModuleClasses

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private MethodSpec generateGetExcludedModuleClasses(Set<String> excludedClassNames) {
  TypeName wildCardOfObject = WildcardTypeName.subtypeOf(Object.class);
  ParameterizedTypeName classOfWildcardOfObjet =
      ParameterizedTypeName.get(ClassName.get(Class.class), wildCardOfObject);
  ParameterizedTypeName setOfClassOfWildcardOfObject =
      ParameterizedTypeName.get(ClassName.get(Set.class), classOfWildcardOfObjet);
  ParameterizedTypeName hashSetOfClassOfWildcardOfObject =
      ParameterizedTypeName.get(ClassName.get(HashSet.class), classOfWildcardOfObjet);
  MethodSpec.Builder builder = MethodSpec.methodBuilder("getExcludedModuleClasses")
      .addModifiers(Modifier.PUBLIC)
      .addAnnotation(Override.class)
      .returns(setOfClassOfWildcardOfObject);

  if (excludedClassNames.isEmpty()) {
    builder.addStatement("return $T.emptySet()", Collections.class);
  } else {
    builder.addStatement(
        "$T excludedClasses = new $T()", setOfClassOfWildcardOfObject,
        hashSetOfClassOfWildcardOfObject);
    for (String excludedClassName : excludedClassNames) {
      // TODO: Remove this when we no longer support manifest parsing.
      // Using a Literal ($L) instead of a type ($T) to get a fully qualified import that allows
      // us to suppress deprecation warnings. Aimed at deprecated GlideModules.
      builder.addStatement("excludedClasses.add($L.class)", excludedClassName);
    }
    builder.addStatement("return excludedClasses");
  }

  return builder.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:AppModuleGenerator.java


示例19: generateConstructors

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
private List<MethodSpec> generateConstructors() {
  ParameterizedTypeName classOfTranscodeType =
      ParameterizedTypeName.get(ClassName.get(Class.class), transcodeTypeName);

  TypeName wildcardOfObject = WildcardTypeName.subtypeOf(Object.class);
  ParameterizedTypeName requestBuilderOfWildcardOfObject =
      ParameterizedTypeName.get(ClassName.get(requestBuilderType), wildcardOfObject);

  MethodSpec firstConstructor =
      MethodSpec.constructorBuilder()
          .addParameter(classOfTranscodeType, "transcodeClass")
          .addParameter(requestBuilderOfWildcardOfObject, "other")
      .addStatement("super($N, $N)", "transcodeClass", "other")
      .build();

  ClassName context = ClassName.get("android.content", "Context");
  ClassName glide = ClassName.get("com.bumptech.glide", "Glide");
  ClassName requestManager = ClassName.get("com.bumptech.glide", "RequestManager");
  MethodSpec secondConstructor =
      MethodSpec.constructorBuilder()
          .addParameter(glide, "glide")
          .addParameter(requestManager, "requestManager")
          .addParameter(classOfTranscodeType, "transcodeClass")
          .addParameter(context, "context")
          .addStatement(
              "super($N, $N ,$N, $N)", "glide", "requestManager", "transcodeClass", "context")
          .build();
  return ImmutableList.of(firstConstructor, secondConstructor);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:RequestBuilderGenerator.java


示例20: statement

import com.squareup.javapoet.WildcardTypeName; //导入依赖的package包/类
public static JavaFile statement(Domain ontology) {
	
	ClassName name = ClassName.get(ontology.getTargetPackage(), ontology.getName() + MARKER_MDC);

	ClassName markerName = MarkerGenerator.getName(ontology);
	
    TypeName wildcard = WildcardTypeName.subtypeOf(DomainMarker.class);
    TypeName classOfAny = ParameterizedTypeName.get(ClassName.get(Class.class), wildcard);
    
	ParameterSpec type = ParameterSpec.builder(classOfAny, "type").build();

	return JavaFile.builder(name.packageName(), TypeSpec.classBuilder(name)
				.superclass(ParameterizedTypeName.get( ClassName.get(DomainMdc.class), markerName))
				.addModifiers(Modifier.PUBLIC)
				.addMethod(MethodSpec.constructorBuilder()
					.addModifiers(Modifier.PUBLIC)
					.addStatement("super($T.QUALIFIER)", markerName)
					.build()
				)
				.addMethod(MethodSpec.methodBuilder("createMarker")
						.addModifiers(Modifier.PUBLIC)
						.addStatement("return new $T()", markerName)
						.returns(markerName)
						.build()
					)
				.addMethod(MethodSpec.methodBuilder("supports")
						.addModifiers(Modifier.PUBLIC)
						.addParameter(type)
						.addStatement("return $T.class == $N", markerName, type)
						.returns(boolean.class)
						.build()
					)
				.build())
			
			.build();
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:37,代码来源:MdcGenerator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ImmutableRangeMap类代码示例发布时间:2022-05-21
下一篇:
Java GcmPubSub类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap