可以龙目岛.ToString 包含来自超类型的字段,而不使用 callSuper



我有一个AbstractJPA实体,我正在使用Lombok为所有子类生成toString()方法。 我希望字段id包含在超类上,但我想这样做,使id字段似乎是子类的一部分。 因此,例如,而不是得到这个:

AggregatedSalesOrder(super=AbstractOCIDEntity(super=Entity of type com.example.domain.models.AggregatedSalesOrder with id: null), bucketIndex=null, quantity=null)

我会得到:

AggregatedSalesOrder(id: null, bucketIndex=null, quantity=null)

思潮?

TIA,奥莱

我知道

这是一百年后的事情,你可能不再使用 Java,但现在你可以用 @ToString(callSuper = true) 装饰类,它还会输出超类的字段。希望它对某人有用。

最新更新