AbstractJClass usedCaseClassType = caseClasses.get(interfaceMethod.name()).narrow(constructorMethod.typeParams());
if (!interfaceMethod.params().isEmpty() || interfaceMethod.hasVarArgs()) {
boolean hasNullChecks = false;
for (JVar param1: interfaceMethod.params()) {
if (param1.type().isReference() && !isNullable(param1)) {
JConditional nullCheck = constructorMethod.body()._if(JExpr.ref(param1.name()).eq(JExpr._null()));
JInvocation nullPointerExceptionConstruction = JExpr._new(types._NullPointerException);
nullPointerExceptionConstruction.arg(JExpr.lit("Argument shouldn't be null: '" + param1.name() + "' argument in static method invocation: '" + constructorMethod.name() + "' in class " + valueClass.fullName()));
nullCheck._then()._throw(nullPointerExceptionConstruction);
hasNullChecks = true;
}
}
JVar param1 = interfaceMethod.listVarParam();
if (param1 != null) {
if (param1.type().isReference() && !isNullable(param1)) {
JConditional nullCheck = constructorMethod.body()._if(JExpr.ref(param1.name()).eq(JExpr._null()));
JInvocation nullPointerExceptionConstruction = JExpr._new(types._NullPointerException);
nullPointerExceptionConstruction.arg(JExpr.lit("Argument shouldn't be null: '" + param1.name() + "' argument in static method invocation: '" + constructorMethod.name() + "' in class " + valueClass.fullName()));
nullCheck._then()._throw(nullPointerExceptionConstruction);
hasNullChecks = true;
}
}
if (hasNullChecks) {
JAnnotationUse annotation = constructorMethod.annotate(SuppressWarnings.class);