Trying to iterate and print detailsResp data in loggers
I used streams code to print xml object schema file data to iterate and print in object data value in logger but every time it's printing hash code format value only. highly appreciate your response on my query
sample response data : GetObjectDetailsResponse detailsResp :
<ns2:GetObjectDetailsResponse xmlns="http://../../schema">
<header>
...
</header>
<ns2:addressDetails>
...
</ns2:addressDetails>
<ns2:accountNumberList>
<accountNumber>123456789</accountNumber>
<accountType>Saving</accountType>
</ns2:accountNumberList>
</ns2:GetObjectDetailsResponse>
public class ExampleData {
public ObjectDetails processData(GetObjectDetailsResponse detailsResp){
value = processDetails(elementTag, index, detailsResp.getAccountNumberList());
detailsResp.getAccountNumberList().stream().forEach(item -> logDebug("print getAccountNumberList value--->" + item);
}
}
You can rely on 3rd party libraries for logging purpose (like the
ToStringBuilderfrom apache commons-lang3)You can then have readable from with one line of code
You can also add XJC-plugin during XSD -> JAVA code generation like the
-XtoStringXJC-plugin of jaxb-tools