Consistently use class literals for primitive types

To improve consistency and avoid confusion regarding primitive types
and their wrapper types, this commit ensures that we always use class
literals for primitive types.

For example, instead of using the `Void.TYPE` constant, we now
consistently use `void.class`.
This commit is contained in:
Sam Brannen
2024-01-30 15:15:47 +01:00
parent 95a3f3bb6e
commit db535863dd
33 changed files with 231 additions and 231 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ class MethodParameterTests {
@BeforeEach
void setup() throws NoSuchMethodException {
method = getClass().getMethod("method", String.class, Long.TYPE);
method = getClass().getMethod("method", String.class, long.class);
stringParameter = new MethodParameter(method, 0);
longParameter = new MethodParameter(method, 1);
intReturnType = new MethodParameter(method, -1);
@@ -72,7 +72,7 @@ class MethodParameterTests {
assertThat(intReturnType).isNotEqualTo(stringParameter);
assertThat(intReturnType).isNotEqualTo(longParameter);
Method method = getClass().getMethod("method", String.class, Long.TYPE);
Method method = getClass().getMethod("method", String.class, long.class);
MethodParameter methodParameter = new MethodParameter(method, 0);
assertThat(methodParameter).isEqualTo(stringParameter);
assertThat(stringParameter).isEqualTo(methodParameter);
@@ -86,7 +86,7 @@ class MethodParameterTests {
assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode());
assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode());
Method method = getClass().getMethod("method", String.class, Long.TYPE);
Method method = getClass().getMethod("method", String.class, long.class);
MethodParameter methodParameter = new MethodParameter(method, 0);
assertThat(methodParameter.hashCode()).isEqualTo(stringParameter.hashCode());
assertThat(methodParameter.hashCode()).isNotEqualTo(longParameter.hashCode());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ class SynthesizingMethodParameterTests {
@BeforeEach
void setUp() throws NoSuchMethodException {
method = getClass().getMethod("method", String.class, Long.TYPE);
method = getClass().getMethod("method", String.class, long.class);
stringParameter = new SynthesizingMethodParameter(method, 0);
longParameter = new SynthesizingMethodParameter(method, 1);
intReturnType = new SynthesizingMethodParameter(method, -1);
@@ -63,7 +63,7 @@ class SynthesizingMethodParameterTests {
assertThat(intReturnType).isNotEqualTo(stringParameter);
assertThat(intReturnType).isNotEqualTo(longParameter);
Method method = getClass().getMethod("method", String.class, Long.TYPE);
Method method = getClass().getMethod("method", String.class, long.class);
MethodParameter methodParameter = new SynthesizingMethodParameter(method, 0);
assertThat(methodParameter).isEqualTo(stringParameter);
assertThat(stringParameter).isEqualTo(methodParameter);
@@ -83,7 +83,7 @@ class SynthesizingMethodParameterTests {
assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode());
assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode());
Method method = getClass().getMethod("method", String.class, Long.TYPE);
Method method = getClass().getMethod("method", String.class, long.class);
SynthesizingMethodParameter methodParameter = new SynthesizingMethodParameter(method, 0);
assertThat(methodParameter.hashCode()).isEqualTo(stringParameter.hashCode());
assertThat(methodParameter.hashCode()).isNotEqualTo(longParameter.hashCode());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -303,7 +303,7 @@ class TypeDescriptorTests {
void fieldArray() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("intArray"));
assertThat(typeDescriptor.isArray()).isTrue();
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(Integer.TYPE);
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(int.class);
assertThat(typeDescriptor.toString()).isEqualTo("int[]");
}
@@ -359,7 +359,7 @@ class TypeDescriptorTests {
assertThat(typeDescriptor.isArray()).isFalse();
assertThat(typeDescriptor.isCollection()).isFalse();
assertThat(typeDescriptor.isMap()).isFalse();
assertThat(typeDescriptor.getType()).isEqualTo(Integer.TYPE);
assertThat(typeDescriptor.getType()).isEqualTo(int.class);
assertThat(typeDescriptor.getObjectType()).isEqualTo(Integer.class);
}
@@ -369,7 +369,7 @@ class TypeDescriptorTests {
assertThat(typeDescriptor.isArray()).isTrue();
assertThat(typeDescriptor.isCollection()).isFalse();
assertThat(typeDescriptor.isMap()).isFalse();
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(Integer.TYPE);
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(int.class);
}
@Test