Use Class#componentType() for consistency with arrayType()

Java 12 introduced java.lang.Class#componentType() as a shortcut for
getComponentType().

Since we started using arrayType() in fe5560400c, this commit switches
to componentType() for consistent API usage style.
This commit is contained in:
Sam Brannen
2023-08-07 12:43:40 +03:00
parent 96fd3c10fb
commit 526fc391ee
40 changed files with 88 additions and 88 deletions

View File

@@ -258,8 +258,8 @@ public abstract class AbstractExpressionTests {
}
if (value.getClass().isArray()) {
StringBuilder sb = new StringBuilder();
if (value.getClass().getComponentType().isPrimitive()) {
Class<?> primitiveType = value.getClass().getComponentType();
if (value.getClass().componentType().isPrimitive()) {
Class<?> primitiveType = value.getClass().componentType();
if (primitiveType == Integer.TYPE) {
int[] l = (int[]) value;
sb.append("int[").append(l.length).append("]{");
@@ -287,10 +287,10 @@ public abstract class AbstractExpressionTests {
" in ExpressionTestCase.stringValueOf()");
}
}
else if (value.getClass().getComponentType().isArray()) {
else if (value.getClass().componentType().isArray()) {
List<Object> l = Arrays.asList((Object[]) value);
if (!isNested) {
sb.append(value.getClass().getComponentType().getName());
sb.append(value.getClass().componentType().getName());
}
sb.append('[').append(l.size()).append("]{");
int i = 0;
@@ -306,7 +306,7 @@ public abstract class AbstractExpressionTests {
else {
List<Object> l = Arrays.asList((Object[]) value);
if (!isNested) {
sb.append(value.getClass().getComponentType().getName());
sb.append(value.getClass().componentType().getName());
}
sb.append('[').append(l.size()).append("]{");
int i = 0;

View File

@@ -260,7 +260,7 @@ class ReflectionHelperTests extends AbstractExpressionTests {
assertThat(newArray).hasSize(1);
Object firstParam = newArray[0];
assertThat(firstParam.getClass().getComponentType()).isEqualTo(String.class);
assertThat(firstParam.getClass().componentType()).isEqualTo(String.class);
Object[] firstParamArray = (Object[]) firstParam;
assertThat(firstParamArray).containsExactly("a", "b", "c");
}