У меня есть базовый класс
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FurnitureBillingRequest implements JSONAble<FurnitureBillingRequest> {
private static final Gson gsonSerializer;
static {
gsonSerializer = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
}
@Expose
protected String name;
@Expose
protected long date;
@Expose
protected String phone;
@Expose
protected List<BillItemRO> items;
@Expose
protected int totalAmount;
@Expose
protected int amountPaid;
@Expose
protected String remark;
@Expose
protected String address;
public FurnitureBillingRequest(String name, long date, String phone, int totalAmount,
int amountPaid, String remark, String address) {
this(name, date, phone, new ArrayList<>(), totalAmount, amountPaid, remark, address);
}
public String toJson() {
return gsonSerializer.toJson(this);
}
public FurnitureBillingRequest toObject(String json) {
return gsonSerializer.fromJson(json, FurnitureBillingRequest.class);
}
@Override
public boolean equals(Object that) {
if (!(that instanceof FurnitureBillingRequest)) {
return false;
}
FurnitureBillingRequest thatFurnitureBillingRequest = (FurnitureBillingRequest) that;
if (!StringUtils.equals(this.name, thatFurnitureBillingRequest.name)) return false;
if (this.date != thatFurnitureBillingRequest.date) return false;
if (!StringUtils.equals(this.phone, thatFurnitureBillingRequest.phone)) return false;
if (!this.items.equals(thatFurnitureBillingRequest.items)) return false;
if (this.totalAmount != thatFurnitureBillingRequest.totalAmount) return false;
if (this.amountPaid != thatFurnitureBillingRequest.amountPaid) return false;
return true;
}
}
И подкласс, расширяющийся следующим образом
@Getter
@Setter
@NoArgsConstructor
public class UpdateBillRequest extends FurnitureBillingRequest {
private static final Gson gsonSerializer;
static {
gsonSerializer = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
}
@Expose
private String uid;
@Builder
public UpdateBillRequest(String uid, String name, long date, String phone, List<BillItemRO> items, int totalAmount, int amountPaid, String remark, String address) {
super(name, date, phone, items, totalAmount, amountPaid, remark, address);
this.uid = uid;
}
public UpdateBillRequest(String uid, String name, long date, String phone, int totalAmount, int amountPaid, String remark, String address) {
super(name, date, phone, totalAmount, amountPaid, remark, address);
this.uid = uid;
}
public String toJson() {
return gsonSerializer.toJson(this);
}
public FurnitureBillingRequest toObject(String json) {
return gsonSerializer.fromJson(json, FurnitureBillingRequest.class);
}
}
Я написал модульный тест, чтобы проверить, хорошо ли создан json.
public class UpdateBillRequestTest {
@Test
public void toJson() {
UpdateBillRequest request = UpdateBillRequest.builder()
.date(1234567868L)
.uid("9i09909-90i90-8u90")
.name("kuldeep")
.phone("9535580366")
.build();
System.out.println(request.toJson());
}
@Test
public void toObject() {
}
}
Но когда я пытаюсь скомпилировать код, он заканчивается ошибками
[ОШИБКА] / Пользователи / kuldeep / Работа / Репозитории / Биллинг / BillingModel / src / main / java / com / tarkshala / services/lambda/model/UpdateBillRequest.java:[24,5] builder () в com.tarkshala.services.lambda.model.UpdateBillRequest не может переопределить builder () в com.tarkshala.services.lambda.model.FurnitureBillingRequest [ERROR] returnТип com.tarkshala.services.lambda.model.UpdateBillRequest.UpdateBillRequestBuilder не совместим с com.tarkshala.services.lambda.model.FurnitureBillingRequest.FurnitureBillingRequestBuilder
Понятия не имею, что происходит