use of org.sonar.java.matcher.TypeCriteria in project sonar-java by SonarSource.
the class ImmediateReverseBoxingCheck method unboxingInvocationMatchers.
private static MethodMatcherCollection unboxingInvocationMatchers() {
MethodMatcherCollection matchers = MethodMatcherCollection.create();
for (Entry<String, String> type : PRIMITIVE_TYPES_BY_WRAPPER.entrySet()) {
String primitiveType = type.getValue();
TypeCriteria typeCriteria;
if ("char".equals(primitiveType) || "boolean".equals(primitiveType)) {
typeCriteria = TypeCriteria.is(type.getKey());
} else {
typeCriteria = TypeCriteria.subtypeOf("java.lang.Number");
}
matchers.add(MethodMatcher.create().callSite(typeCriteria).name(primitiveType + "Value").withoutParameter());
}
return matchers;
}
Aggregations