Some small bugs of generation fixed

This commit is contained in:
Gavriil Sitnikov 2017-08-04 19:20:44 +03:00
parent 81a5593bbc
commit f415ad92f1
2 changed files with 14 additions and 16 deletions

View File

@ -9,11 +9,11 @@ import android.support.annotation.Nullable;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import {{ packageName }}.*;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -49,9 +49,7 @@ public class {% include 'blocks/class/classtype.twig' with { type: type } %} ext
super.validate();
{%- include 'blocks/class/fields-validate.twig' with { fields: fields } %}
}
{% if parent is not null %}
@Override
{%- endif %}
protected void copyTo(@NonNull final {% include 'blocks/class/classtype.twig' with { type: type } %} destination) {
{%- if parent is not null %}
super.copyTo(destination);
@ -83,12 +81,12 @@ public class {% include 'blocks/class/classtype.twig' with { type: type } %} ext
{%- include 'blocks/class/fields-equals.twig' with { fields: fields } -%};
}
private void writeObject(@NonNull final ObjectOutputStream outputStream) {
private void writeObject(@NonNull final ObjectOutputStream outputStream) throws IOException {
{%- include 'blocks/class/fields-write-object.twig' with { fields: fields } %}
}
@SuppressWarnings("unchecked")
private void readObject(@NonNull final ObjectInputStream inputStream) {
private void readObject(@NonNull final ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
{%- include 'blocks/class/fields-read-object.twig' with { fields: fields } %}
}

View File

@ -43,7 +43,7 @@ LoganSquareJsonModel
{%- elseif valueType.baseTypeName == "Decimal" -%}
BigDecimal
{%- elseif valueType.baseTypeName == "Bool" -%}
{%- if tryUsePrimitive -%}bool{%- else -%}Boolean{%- endif -%}
{%- if tryUsePrimitive -%}boolean{%- else -%}Boolean{%- endif -%}
{%- elseif valueType.baseTypeName == "Map" -%}
Map<{{ self.formatNonOptionalValueType(valueType.keysType, false) }}, {{ self.formatNonOptionalValueType(valueType.valuesType, false) }}>
{%- elseif valueType.baseTypeName == "Array" -%}
@ -90,7 +90,7 @@ new HashMap<>({{ fieldName }})
{%- if optional -%}
{{ object }}.{{ fieldName }} = new JsonOptional({{- self.formatNullableValueSetter(fieldName, valueType, nullable) -}});
{%- elseif nullable -%}
{{ object }}.{{ fieldName }} = self.formatNullableValueSetter(fieldName, valueType, nullable) -}};
{{ object }}.{{ fieldName }} = self.formatNullableValueSetter(fieldName, valueType, nullable);
{%- else -%}
{{ object }}.{{ fieldName }} = {{ fieldName }};
{%- endif -%}
@ -119,7 +119,7 @@ Collections.unmodifiableMap({{ fieldName }})
{%- if optional -%}
return new JsonOptional({{- self.formatNullableValueGetter(fieldName, valueType, nullable) -}});
{%- elseif nullable -%}
return self.formatNullableValueGetter(fieldName, valueType, nullable) -}};
return self.formatNullableValueGetter(fieldName, valueType, nullable);
{%- else -%}
return this.{{ fieldName }};
{%- endif -%}
@ -183,20 +183,20 @@ writeObject({{ fieldName }})
{% macro formatReadObject(valueType, nullable, optional) %}
{% import _self as self %}
{%- if nullable or optional -%}
({{ self.formatValueType(valueType, nullable, optional) }}) readObject()
({{ self.formatValueType(valueType, nullable, optional) }}) inputStream.readObject()
{%- else -%}
{%- if valueType.baseTypeName == "Int" -%}
readInt()
inputStream.readInt()
{%- elseif valueType.baseTypeName == "Long" -%}
readLong()
inputStream.readLong()
{%- elseif valueType.baseTypeName == "Double" -%}
readDouble()
inputStream.readDouble()
{%- elseif valueType.baseTypeName == "String" -%}
readUTF()
inputStream.readUTF()
{%- elseif valueType.baseTypeName == "Bool" -%}
readBoolean()
inputStream.readBoolean()
{%- else -%}
({{ self.formatValueType(valueType, nullable, optional) }}) readObject()
({{ self.formatValueType(valueType, nullable, optional) }}) inputStream.readObject()
{%- endif -%}
{%- endif -%}
{% endmacro %}