I'm reading the code base of a project, and here's some code I can't under stand:
protected BaseApiCommand(String apiName, ApiParams params, boolean isGetRequest) {
this.apiName = apiName;
this.apiParams = params;
this.isGet = isGetRequest;
if (apiParams == null) {
apiParams = new ApiParams();
}
}
public static BaseApiCommand createCommand(String apiName, boolean isGet, ApiParams params) {
return new BaseApiCommand(apiName, params, isGet);
}
I know it's about publication, but I just can't understand why it's unsafe otherwise to expose the constructor directly. Can anyone explain it in detail ?