Skip to content

Commit

Permalink
Merge pull request #144 from talklittle/development
Browse files Browse the repository at this point in the history
DynamicFieldType: restore TypeConverter lookup
  • Loading branch information
EricKuck committed Mar 10, 2016
2 parents db88169 + c46c9a7 commit 51c81e1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.bluelinelabs.logansquare.processor.type.field;

import com.bluelinelabs.logansquare.processor.ObjectMapperInjector;
import com.bluelinelabs.logansquare.LoganSquare;
import com.squareup.javapoet.MethodSpec.Builder;
import com.squareup.javapoet.TypeName;

Expand Down Expand Up @@ -30,8 +30,8 @@ public TypeName getNonPrimitiveTypeName() {

@Override
public void parse(Builder builder, int depth, String setter, Object... setterFormatArgs) {
setter = replaceLastLiteral(setter, ObjectMapperInjector.getTypeConverterGetter(mTypeName) + "().parse($L)");
builder.addStatement(setter, expandStringArgs(setterFormatArgs, JSON_PARSER_VARIABLE_NAME));
setter = replaceLastLiteral(setter, "$T.typeConverterFor($T.class).parse($L)");
builder.addStatement(setter, expandStringArgs(setterFormatArgs, LoganSquare.class, mTypeName, JSON_PARSER_VARIABLE_NAME));
}

@Override
Expand All @@ -40,7 +40,8 @@ public void serialize(Builder builder, int depth, String fieldName, List<String>
builder.beginControlFlow("if ($L != null)", getter);
}

builder.addStatement(ObjectMapperInjector.getTypeConverterGetter(mTypeName) + "().serialize($L, $S, $L, $L)", getter, isObjectProperty ? fieldName : null, isObjectProperty, JSON_GENERATOR_VARIABLE_NAME);
builder.addStatement("$T.typeConverterFor($T.class).serialize($L, $S, $L, $L)", LoganSquare.class, mTypeName, getter, isObjectProperty
? fieldName : null, isObjectProperty, JSON_GENERATOR_VARIABLE_NAME);

if (!mTypeName.isPrimitive() && checkIfNull) {
if (writeIfNull) {
Expand Down

0 comments on commit 51c81e1

Please sign in to comment.