29 lines
991 B
Plaintext
29 lines
991 B
Plaintext
# @Context cycle tracking: it works for a bean target and cannot work for a record target
|
|
|
|
bean target + @Context CycleContext : ann.manager.manager is ann? true
|
|
record target + the same @Context : java.lang.StackOverflowError
|
|
|
|
--- why: the generated record mapping recurses BEFORE it can call the constructor ---
|
|
public Probes.EmployeeRecord toRecord(Probes.Employee employee, CycleContext context) {
|
|
Probes.EmployeeRecord target = context.lookup( employee, Probes.EmployeeRecord.class );
|
|
if ( target != null ) {
|
|
return target;
|
|
}
|
|
|
|
if ( employee == null ) {
|
|
return null;
|
|
}
|
|
|
|
String name = null;
|
|
Probes.EmployeeRecord manager = null;
|
|
|
|
name = employee.name;
|
|
manager = toRecord( employee.manager, context );
|
|
|
|
Probes.EmployeeRecord employeeRecord = new Probes.EmployeeRecord( name, manager );
|
|
|
|
context.remember( employee, employeeRecord );
|
|
|
|
return employeeRecord;
|
|
}
|