Field stream in eclipse code template

Can you create loops in code templates, for example, I want to print all the fields in a class. Is there a template for this?

+5
source share
3 answers

Since I did not find what I was looking for, I put it in the plugin . It supports options. If you have classa name Companywith fields companyName, companyTypeetc., It will generate print statements, as shown below, if you choose the logger.debug option:

if (logger.isDebugEnabled()) {
    logger.debug("Company Name " + company.getCompanyName());
    logger.debug("Company Type " + company.getCompanyType());
}

template-variation

+4
source

Assuming you're talking about Java > Editor > Templates, the link (may be out of date) here

SO useful-eclipse-java-code-templates .

toString(), : toString() :

+7

Eclipse can generate toString(), which includes a listing of all fields and their string values, if that is what you are after.

+4
source

All Articles