我正在使用Parceler for FragmentArgs和RealmObjects(和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() {}
}
更新2
仅当我使用时才会发生这种情况
@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 注释中的包裹
@Arg(bundler = ParcelerArgsBundler.class) ProjectInfo projectInfo;