[英]Is there a way i can use the existing instance (object) of the class
I have a class implemented as below我有一个类实现如下
@Builder
class A extends B {
@Getter
public List<Customer> cusromers = new ArrayList<>();
@Override
public void add(){
c.add(obj);
}
}
Below is in different project以下是在不同的项目中
class C {
public Student<T, C> getValues() {
return A.builder().customers(getCustomers()).build()
}
}
The below is different project and has dependency of the above's project以下是不同的项目,并且具有上述项目的依赖关系
@Test
class Test {
// I need to check the instance of class A and test if the instance has added some modifications for the list above stated class
}
Please any one help me on this.请任何人帮助我。 Excuse me if i do any mistake对不起,如果我做错了什么
You probably need some @Getter
and @Setter
annotation in combination with your @Builder
.您可能需要将一些@Getter
和@Setter
注释与您的@Builder
结合使用。
@Getter
@Setter
@Builder
class A extends B {
public List<Customer> customers = new ArrayList<>();
@Override
public void add(){
customers.add(new Customer());
}
}
@Test
class Test {
A a = new A():
List<Customer> customers = a.getCustomers();
assertEquals(1, customers.size());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.