Skip to content

Commit

Permalink
removed static getAdapter method
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhramanan committed Dec 7, 2017
1 parent 1296b52 commit 9e35c9b
Showing 1 changed file with 1 addition and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public TypeSpec getTypeAdapterFactorySpec() {
TypeSpec.Builder adapterBuilder = TypeSpec.classBuilder(fileName)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addSuperinterface(TypeAdapterFactory.class)
.addMethod(createStaticAdapterCreationMethod())
.addMethod(getCreateMethodSpec());

return adapterBuilder.build();
Expand All @@ -53,27 +52,7 @@ private MethodSpec getCreateMethodSpec() {
.returns(ParameterizedTypeName.get(ClassName.get(TypeAdapter.class), genericType))
.addAnnotation(suppressions)
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC);

builder.addCode("return getAdapter(gson, type);\n");

return builder.build();
}

@NotNull
private MethodSpec createStaticAdapterCreationMethod() {
TypeVariableName genericType = TypeVariableName.get("T");
AnnotationSpec suppressions = AnnotationSpec.builder(SuppressWarnings.class)
.addMember("value", "\"unchecked\"")
.addMember("value", "\"rawtypes\"")
.build();
MethodSpec.Builder builder = MethodSpec.methodBuilder("getAdapter")
.addTypeVariable(genericType)
.addParameter(Gson.class, "gson")
.addParameter(ParameterizedTypeName.get(ClassName.get(TypeToken.class), genericType), "type")
.returns(ParameterizedTypeName.get(ClassName.get(TypeAdapter.class), genericType))
.addAnnotation(suppressions)
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.addModifiers(Modifier.PUBLIC)
.addCode("Class<? super T> clazz = type.getRawType();\n");

for (ClassInfo classInfo : classInfoList) {
Expand Down

0 comments on commit 9e35c9b

Please sign in to comment.