包裹和龙目岛不能一起工作? [英] Parceler and Lombok not working together?

查看:92
本文介绍了包裹和龙目岛不能一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的android应用程序,我使用包裹库和lombok库.

For my android app I use the parceler library and the lombok library.

这些是我班上的注释:

@Table
@ToString
@Getter
@NoArgsConstructor
@Parcel
public class MyClass {

但是,在gradle构建期间,Parceler抱怨没有默认的空构造函数.那么这是否意味着它无法识别@NoArgsConstructor批注,而这两个根本无法协同工作?因为SugarORM没有问题.还是我只是想念什么?

However, during gradle build, Parceler complains that there is no default empty constructor. So does this mean it doesn't recognize the @NoArgsConstructor annotation and these two simply won't work together? Because e.g. SugarORM has no probs with it. Or am I just missing something?

推荐答案

这涉及Lombok如何向您的班级添加代码. Lombok在Java注释处理器中使用已知技巧来将代码添加到您的课程中.在注释处理器回合期间,此添加的代码对于Parceler不可见,并使添加的no-args构造函数对于Parceler而言是未知的.

This gets into how Lombok adds code to your class. Lombok uses a known trick in the Java annotation processor to add code to your class. This added code is not visible to Parceler during the annotation processor round and makes the added no-args constructor unknown to Parceler.

我建议手动添加no-args构造函数,并用@ParcelConstructor注释现有的构造函数(我假设您有一个),或者考虑使用Lombok分支

I'd recommend adding the no-args constructor manually, annotating the existing constructor with @ParcelConstructor (I assume you have one) or consider using the Lombok fork Hrisey that has an @Parcelable annotation.

我们最近对此有一个问题/疑问: https://github.com/johncarl81/包裹/问题/177

We had an issue/question about this recently: https://github.com/johncarl81/parceler/issues/177

这篇关于包裹和龙目岛不能一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆