Parceler:无法找到类型为RealmList <backend.model.invitation>的读/写生成器,用于backend.model.ProjectInfo#invitations

时间:2016-11-23 09:42:26

标签: java android realm parceler

我使用Parceler FragmentArgsRealmObjects(和Lombok)并获得以下构建错误。

Error:(73, 70) error: Parceler: Unable to find read/write generator for type io.realm.RealmList<backend.model.Invitation> for backend.model.ProjectInfo#invitations

我的类ProjectInfo看起来像这样

@Parcel(implementations = {ProjectInfoRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {ProjectInfo.class})
public class ProjectInfo extends RealmObject
{
@Getter @Setter @PrimaryKey long projectId;

@ParcelPropertyConverter(RealmListParcelConverter.class) @Getter @Setter @Ignore RealmList<Invitation> invitations;
@ParcelPropertyConverter(RealmListParcelConverter.class) @Getter @Setter         RealmList<Submission> submissions;
}

Classes Submission和Invitation都是非常简单的数据结构,也扩展了RealmObject

班级RealmListParcelConverter如下所示:

public class RealmListParcelConverter implements TypeRangeParcelConverter<RealmList<? extends RealmObject>, RealmList<? extends RealmObject>>
{
    private static final int NULL = -1;

    @Override
    public void toParcel(RealmList<? extends RealmObject> input, Parcel parcel)
    {
        parcel.writeInt(input == null ? NULL : input.size());
        if(input != null)
        {
            for(RealmObject item : input)
            {
                parcel.writeParcelable(Parcels.wrap(item), 0);
            }
        }
    }

    @Override
    public RealmList fromParcel(Parcel parcel)
    {
        int       size = parcel.readInt();
        RealmList list = new RealmList();
        for(int i = 0; i < size; i++)
        {
            Parcelable parcelable = parcel.readParcelable(getClass().getClassLoader());
            list.add((RealmObject) Parcels.unwrap(parcelable));
        }
        return list;
    }
}

我做错了什么?

更新1

邀请班

@Parcel(implementations = {InvitationRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {Invitation.class})
public class Invitation extends RealmObject
{
    @Getter @Setter long    accountId;
    @Getter @Setter long    projectId;
    @Getter @Setter boolean declined;
    @Getter @Setter String  name;
    public Invitation() {}
}

提交类

@Parcel(implementations = {SubmissionRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {Submission.class})
public class Submission extends RealmObject
{
    @Getter @Setter @PrimaryKey long    id;
    @Getter @Setter             long    creator;
    @Getter @Setter             float   length;

    public Submission() {}

}

UPDATE2

只有在我使用

时才会发生这种情况
@Parcel(implementations = {ProjectInfoRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {ProjectInfo.class})

如果我使用简单的

@Parcel

它在运行时崩溃

时崩溃
org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for io.realm.ProjectInfoRealmProxy

更新3

我正在使用@Args注释中的parcel,就像这样

@Arg(bundler = ParcelerArgsBundler.class) ProjectInfo projectInfo;

0 个答案:

没有答案