Skip to content

Commit

Permalink
correction to handling of V type token for Map<K, V> in gson
Browse files Browse the repository at this point in the history
+ typo correction
  • Loading branch information
elucash committed Jan 8, 2016
1 parent 17bd84b commit d64547a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
Expand Up @@ -83,10 +83,10 @@ private static class [type.name]TypeAdapter extends TypeAdapter<[t]> {
private static final TypeToken<[im]> [toConstant type.name]_IMMUTABLE = TypeToken.get([im].class);
[for a in allAttributes]
[if a.requiresMarshalingAdapter]
private static final TypeToken<[a.elementType]> [toConstant a.name]_TYPE_TOKEN = [if a.nonRawElemementType]new TypeToken<[a.elementType]>() {}[else]TypeToken.get([a.elementType].class)[/if];
private static final TypeToken<[a.elementType]> [toConstant a.name]_TYPE_TOKEN = [if a.nonRawElementType]new TypeToken<[a.elementType]>() {}[else]TypeToken.get([a.elementType].class)[/if];
[/if]
[if a.requiresMarshalingSecondaryAdapter]
private static final TypeToken<[a.secondaryElementType]> [toConstant a.name]_SECONDARY_TYPE_TOKEN = new TypeToken<[a.secondaryElementType]>() {};
private static final TypeToken<[a.secondaryElementType]> [toConstant a.name]_SECONDARY_TYPE_TOKEN = [if a.nonRawSecondaryElementType]new TypeToken<[a.secondaryElementType]>() {}[else]TypeToken.get([a.secondaryElementType].class)[/if];
[/if]
[/for]
[for a in allAttributes]
Expand Down
Expand Up @@ -2521,7 +2521,7 @@ return [if type.innerBuilder.isExtending]([type.typeBuilder]) [/if]this;

[template deprecation Attribute a][if a.deprecated]@Deprecated[/if][/template]

[template varargsSafety Attribute a][if a.nonRawElemementType]@SafeVarargs[/if][/template]
[template varargsSafety Attribute a][if a.nonRawElementType]@SafeVarargs[/if][/template]

[template functionClass][if classpath.isJava8]java.util.function.Function[else][guava].base.Function[/if][/template]

Expand Down
Expand Up @@ -861,4 +861,4 @@ import [starImport];

[template deprecation Attribute a][if a.deprecated]@Deprecated[/if][/template]

[template varargsSafety Attribute a][if a.nonRawElemementType]@SafeVarargs[/if][/template]
[template varargsSafety Attribute a][if a.nonRawElementType]@SafeVarargs[/if][/template]
Expand Up @@ -86,12 +86,12 @@ public final class [typeAdaptersName] implements JsonAdapter.Factory {
private static class [type.name]Adapter extends JsonAdapter<[t]> {
[for a in allAttributes]
[if a.requiresMarshalingAdapter]
[if a.nonRawElemementType]
[if a.nonRawElementType]
public static final [a.elementType] [toConstant a.name]_TYPE_OF = null;
[/if]
[/if]
[if a.requiresMarshalingSecondaryAdapter]
[if a.nonRawElemementType]
[if a.nonRawElementType]
public static final [a.secondaryElementType] [toConstant a.name]_SECONDARY_TYPE_OF = null;
[/if]
[/if]
Expand Down Expand Up @@ -140,7 +140,7 @@ private static class [type.name]Adapter extends JsonAdapter<[t]> {
[/template]

[template getAdapterFromMoshi Attribute a Boolean secondary]
[if a.nonRawElemementType]
[if a.nonRawElementType]
this.[a.name][if secondary]Secondary[/if]Adapter = moshi.adapter(getClass().getField("[toConstant a.name][if secondary]_SECONDARY[/if]_TYPE_OF").getGenericType());
[else]
this.[a.name][if secondary]Secondary[/if]Adapter = moshi.adapter([if secondary][a.secondaryElementType][else][a.elementType][/if].class);
Expand Down
Expand Up @@ -704,10 +704,10 @@ public static final class Criteria extends Repositories.Criteria {
private static class Serialization {
[for a in allAttributes]
[if a.requiresMarshalingAdapter]
private static final TypeToken<[a.elementType]> [toConstant a.name]_TYPE_TOKEN = [if a.nonRawElemementType]new TypeToken<[a.elementType]>() {}[else]TypeToken.get([a.elementType].class)[/if];
private static final TypeToken<[a.elementType]> [toConstant a.name]_TYPE_TOKEN = [if a.nonRawElementType]new TypeToken<[a.elementType]>() {}[else]TypeToken.get([a.elementType].class)[/if];
[/if]
[if a.requiresMarshalingSecondaryAdapter]
private static final TypeToken<[a.secondaryElementType]> [toConstant a.name]_SECONDARY_TYPE_TOKEN = new TypeToken<[a.secondaryElementType]>() {};
private static final TypeToken<[a.secondaryElementType]> [toConstant a.name]_SECONDARY_TYPE_TOKEN = [if a.nonRawSecondaryElementType]new TypeToken<[a.secondaryElementType]>() {}[else]TypeToken.get([a.secondaryElementType].class)[/if];
[/if]
[/for]
[for a in allAttributes]
Expand Down
Expand Up @@ -714,10 +714,14 @@ public boolean isDouble() {
return returnType.getKind() == TypeKind.DOUBLE;
}

public boolean isNonRawElemementType() {
public boolean isNonRawElementType() {
return getElementType().indexOf('<') > 0;
}


public boolean isNonRawSecondaryElementType() {
return getSecondaryElementType().indexOf('<') > 0;
}

public boolean isContainerType() {
// TBD replace with typeKind.isContainerKind() ?
return isCollectionType()
Expand Down

0 comments on commit d64547a

Please sign in to comment.