dallasgutauckis/parcelabler

Adding "{private"

Closed this issue · 3 comments

Parcelabler is adding {private after every occurrence of the class name. For instance, for this code:

public class TransformatedForm{
    private Form _form;
    private String _formCategory;
    private ArrayList<CategorisedParameter> _listCategorisedParameters;
}

It gave me following code:

public class TransformatedForm implements Parcelable {


    private Form _form;
    private String _formCategory;
    private ArrayList<CategorisedParameter> _listCategorisedParameters;

    protected TransformatedForm{private(Parcel in) {
        _form = (Form) in.readValue(Form.class.getClassLoader());
        _formCategory = in.readString();
        if (in.readByte() == 0x01) {
            _listCategorisedParameters = new ArrayList<CategorisedParameter>();
            in.readList(_listCategorisedParameters, CategorisedParameter.class.getClassLoader());
        } else {
            _listCategorisedParameters = null;
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(_form);
        dest.writeString(_formCategory);
        if (_listCategorisedParameters == null) {
            dest.writeByte((byte) (0x00));
        } else {
            dest.writeByte((byte) (0x01));
            dest.writeList(_listCategorisedParameters);
        }
    }

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<TransformatedForm{private> CREATOR = new Parcelable.Creator<TransformatedForm{private>() {
        @Override
        public TransformatedForm{private createFromParcel(Parcel in) {
            return new TransformatedForm{private(in);
        }

        @Override
        public TransformatedForm{private[] newArray(int size) {
            return new TransformatedForm{private[size];
        }
    };
}

It doesn't always occur, I think it occurs once you do it with another class, and then you just change code on the editor and submit form again. Hope this will help.

Here's picture:
Screenshot
I took the downer part of code, because there are more occurrences of the class name.

Thanks for the report. Will take a look when I get the chance.

Just playing with the supplied code it looks like we're probably looking for the first space after the class name (as opposed to looking for the first ineligible character). For now, add a space after the class name (before your opening curly brace in the provided example) to have it work as expected.