@@ -112,18 +112,19 @@ ArrayList:
112112- String: "9452541b-c6f9-4316-b254-28d00b327d0d"
113113- String: "4ed0f3c4-5ea3-4dbb-b31c-f92c036af463"
114114
115- ### Set Public Field
115+ ### Customize Property With Lambda
116116``` java
117117TestDto result = fixture. build(TestDto . class)
118118 .with(x - > x. myPublicField = 123 )
119+ .with(x - > x. setMyPrivateField(" HELLO!" ))
119120 .create();
120121```
121122#### Sample Result
122123TestDto:
123- - myPrivateField: String: "349a1f87-9d00-4623-89cb-3031bb84ddb3 "
124+ - myPrivateField: String: "HELLO! "
124125- myPublicField: int: 123
125126
126- ### Set Private Field
127+ ### Set Private Field Using Reflection
127128``` java
128129TestDto result = fixture. build(TestDto . class)
129130 .with(" myPrivateField" , " HELLO!" )
@@ -134,17 +135,6 @@ TestDto:
134135- myPrivateField: String: "HELLO!"
135136- myPublicField: int: 26123854
136137
137- ### Call a Setter
138- ``` java
139- TestDto result = fixture. build(TestDto . class)
140- .with(x - > x. SetMyPrivateField (" HELLO!" ))
141- .create();
142- ```
143- #### Sample Result
144- TestDto:
145- - myPrivateField: String: "HELLO!"
146- - myPublicField: int: 71
147-
148138### Set all fields for type
149139``` java
150140ParentDto result = fixture. build(ParentDto . class)
@@ -166,41 +156,16 @@ ParentDto result = fixture.build(ParentDto.class)
166156``` java
167157TestDto result = fixture. build(TestDto . class)
168158 .without(" myPrivateField" )
169- .create();
170- ```
171- #### Sample Result
172- TestDto:
173- - myPrivateField: String: null
174- - myPublicField: int: -128564
175-
176- ### Omit Primitive Field
177- ``` java
178- TestDto result = fixture. build(TestDto . class)
179159 .without(" myPublicField" )
180160 .create();
181161```
182162#### Sample Result
183163TestDto:
184- - myPrivateField: String: "349a1f87-9d00-4623-89cb-3031bb84ddb3"
164+ - myPrivateField: String: null
185165- myPublicField: int: 0
186166
187-
188- ### Perform Multiple Operations
189- ``` java
190- String child = fixture. create(String . class);
191- ParentDto parent = fixture. build(ParentDto . class)
192- .with(x - > x. addChild(child))
193- .with(x - > x. youngestChild = child)
194- .create();
195- ```
196- #### Sample Result
197- ParentDto:
198- - children: ArrayList:
199- - String: "710ba467-01a7-4bcc-b880-84eda5458989"
200- - String: "9452541b-c6f9-4316-b254-28d00b327d0d"
201- - String: "4ed0f3c4-5ea3-4dbb-b31c-f92c036af463"
202- - String: "349a1f87-9d00-4623-89cb-3031bb84ddb3"
203- - youngestChild: String: "349a1f87-9d00-4623-89cb-3031bb84ddb3"
167+ #### Note
168+ Primitives will receive their default-value, classes will be ` null ` .
204169
205170## Generics
206171Due to Java's type erasure (further reading: [ baeldung] ( https://www.baeldung.com/java-type-erasure ) ), it is difficult to reflect generic classes on runtime and the following doesn't work:
0 commit comments