use of org.sonar.java.resolve.ParametrizedTypeJavaType in project sonar-java by SonarSource.
the class OptionalAsParameterCheck method expectedTypeInsteadOfOptional.
private static Optional<String> expectedTypeInsteadOfOptional(Type type) {
if (type.is(JAVA_UTIL_OPTIONAL)) {
String msg;
if (((JavaType) type).isParameterized()) {
ParametrizedTypeJavaType ptjt = (ParametrizedTypeJavaType) type;
String parameterTypeName = ptjt.substitution(ptjt.typeParameters().get(0)).erasure().name();
msg = formatMsg(parameterTypeName);
} else {
msg = "Specify a type instead.";
}
return Optional.of(msg);
}
return PRIMITIVE_OPTIONALS.stream().filter(type::is).findFirst().map(optional -> formatMsg(optional.substring(JAVA_UTIL_OPTIONAL.length()).toLowerCase()));
}
Aggregations