use of com.puppycrawl.tools.checkstyle.checks.naming.AccessModifier in project checkstyle by checkstyle.
the class XdocsPagesTest method getModulePropertyExpectedValue.
private static String getModulePropertyExpectedValue(Class<?> clss, Object instance, String propertyName) throws Exception {
final Field field = getField(instance.getClass(), propertyName);
String result = null;
if (field != null) {
final Object value = field.get(instance);
if (clss == boolean.class) {
result = value.toString();
} else if (clss == int.class) {
if (value.equals(Integer.MAX_VALUE)) {
result = "java.lang.Integer.MAX_VALUE";
} else {
result = value.toString();
}
} else if (clss == int[].class) {
result = Arrays.toString((int[]) value).replace("[", "").replace("]", "");
if (result.isEmpty()) {
result = "{}";
}
} else if (clss == double[].class) {
result = Arrays.toString((double[]) value).replace("[", "").replace("]", "").replace(".0", "");
if (result.isEmpty()) {
result = "{}";
}
} else if (clss == URI.class) {
if (value != null) {
result = '"' + value.toString() + '"';
}
} else if (clss == Pattern.class) {
if (value != null) {
result = '"' + value.toString().replace("\n", "\\n").replace("\t", "\\t").replace("\r", "\\r").replace("\f", "\\f") + '"';
}
if ("\"$^\"".equals(result)) {
result += " (empty)";
}
} else if (value != null && (clss == SeverityLevel.class || clss == Scope.class)) {
result = value.toString().toLowerCase(Locale.ENGLISH);
} else if (value != null && clss == AccessModifier[].class) {
result = Arrays.toString((Object[]) value).replace("[", "").replace("]", "");
}
if (clss != String.class && clss != String[].class && result == null) {
result = "null";
}
}
return result;
}
Aggregations