use of com.squareup.javapoet.ParameterizedTypeName in project glide by bumptech.
the class RootModuleGenerator method generateGetExcludedModuleClasses.
// TODO: When we drop support for parsing GlideModules from AndroidManifests, remove this method.
private static 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();
}
use of com.squareup.javapoet.ParameterizedTypeName in project storio by pushtorefresh.
the class MappingGenerator method generateJavaFile.
@NotNull
@Override
public JavaFile generateJavaFile(@NotNull StorIOContentResolverTypeMeta storIOSQLiteTypeMeta) {
final ClassName storIOSQLiteTypeClassName = ClassName.get(storIOSQLiteTypeMeta.packageName, storIOSQLiteTypeMeta.simpleName);
ClassName superclass = ClassName.get("com.pushtorefresh.storio.contentresolver", SUFFIX);
ParameterizedTypeName superclassParametrized = ParameterizedTypeName.get(superclass, storIOSQLiteTypeClassName);
final TypeSpec mapping = TypeSpec.classBuilder(storIOSQLiteTypeMeta.simpleName + SUFFIX).addJavadoc("Generated mapping with collection of resolvers\n").addModifiers(PUBLIC).superclass(superclassParametrized).addMethod(createConstructor(storIOSQLiteTypeMeta)).build();
return JavaFile.builder(storIOSQLiteTypeMeta.packageName, mapping).indent(INDENT).build();
}
use of com.squareup.javapoet.ParameterizedTypeName in project storio by pushtorefresh.
the class MappingGenerator method generateJavaFile.
@NotNull
@Override
public JavaFile generateJavaFile(@NotNull StorIOSQLiteTypeMeta storIOSQLiteTypeMeta) {
final ClassName storIOSQLiteTypeClassName = ClassName.get(storIOSQLiteTypeMeta.packageName, storIOSQLiteTypeMeta.simpleName);
ClassName superclass = ClassName.get("com.pushtorefresh.storio.sqlite", SUFFIX);
ParameterizedTypeName superclassParametrized = ParameterizedTypeName.get(superclass, storIOSQLiteTypeClassName);
final TypeSpec mapping = TypeSpec.classBuilder(storIOSQLiteTypeMeta.simpleName + SUFFIX).addJavadoc("Generated mapping with collection of resolvers.\n").addModifiers(PUBLIC).superclass(superclassParametrized).addMethod(createConstructor(storIOSQLiteTypeMeta)).build();
return JavaFile.builder(storIOSQLiteTypeMeta.packageName, mapping).indent(INDENT).build();
}
use of com.squareup.javapoet.ParameterizedTypeName in project tiger by google.
the class Utils method hasBuiltinBinding.
public static boolean hasBuiltinBinding(TypeName type) {
if (!(type instanceof ParameterizedTypeName)) {
return false;
}
ParameterizedTypeName typeName = (ParameterizedTypeName) type;
ClassName rawType = typeName.rawType;
return rawType.equals(ClassName.get(Provider.class)) || rawType.equals(ClassName.get(Lazy.class));
}
use of com.squareup.javapoet.ParameterizedTypeName in project tiger by google.
the class Utils method getElementKeyForBuiltinBinding.
/**
* Return {@link NewBindingKey} for element of the give {@link NewBindingKey} that
* has built-in binding, null if not built-in building.
*/
@Nullable
public static NewBindingKey getElementKeyForBuiltinBinding(NewBindingKey key) {
if (!hasBuiltinBinding(key)) {
return null;
}
ParameterizedTypeName parameterizedTypeName = (ParameterizedTypeName) key.getTypeName();
TypeName typeName = Iterables.getOnlyElement(parameterizedTypeName.typeArguments);
AnnotationSpec qualifier = key.getQualifier();
return NewBindingKey.get(typeName, qualifier);
}
Aggregations