Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.19 KB

File metadata and controls

36 lines (27 loc) · 1.19 KB

⇧ Platform Base

ToStringBuilder Utility

Our project utilizes a custom implementation of the ToStringBuilder similar to what's available in org.apache.commons.lang3.builder.ToStringBuilder. The primary objective behind this is to ensure consistent formatting for our toString() methods throughout the application.

Integration with IntelliJ IDEA

For developers who are familiar with IntelliJ IDEA's code generation methods, we provide templates to seamlessly integrate with our ToStringBuilder utility.

ToStringBuilder (swirlds-base) Template:

public java.lang.String toString() {
    return new com.swirlds.base.utility.ToStringBuilder(this)
#foreach ($member in $members)
    .append("$member.name", $member.accessor)
#end
    .toString();
}

ToStringBuilder with appendSuper (swirlds-base) Template:

public java.lang.String toString() {
    return new com.swirlds.base.utility.ToStringBuilder(this)
    .appendSuper(super.toString())
#foreach ($member in $members)
    .append("$member.name", $member.accessor)
#end
    .toString();
}

Note: Ensure that your IntelliJ IDEA is set up to interpret and use the above templates accurately.