Do not use the linker template . This is not for types with the number of fields required. This is for types with tons of optional fields.
The required properties of builders are set using the constructor. You are not required to define values using methods, which makes these values optional.
This leaves the potential for your object to be only partially constructed. Using a builder for this would be an abuse of design.
With that said, you should decompose your type. I'm not sure if lmd or ctime , or indeed what DataResponse should represent, so I cannot tell you how you should decompose. But I can say that cohesion is what defines it.
isLink , maskInfo and idType can be decomposed into a DataResponseDetails object:
class DataResponseDetails { private boolean isLink; private String maskInfo; private TypeOfId idType; public DataResponseDetails(boolean isLink, String maskInfo, TypeOfId idType) {
Now your DataResponse can consist of DataResponseDetails :
class DataResponse { private DataResponseDetails details; private String response;
Feeling that your constructor requires too much? Share more!
Vince emigh
source share