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:
@@ -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.
|
||||
@@ -619,12 +619,12 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
||||
parameterizedType.getActualTypeArguments().length == 1) {
|
||||
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
|
||||
if (typeArgument instanceof Class<?> classArgument) {
|
||||
return ((classArgument.isArray() && Byte.TYPE == classArgument.componentType()) ||
|
||||
return ((classArgument.isArray() && byte.class == classArgument.componentType()) ||
|
||||
isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
|
||||
supportsInternal(classArgument, false));
|
||||
}
|
||||
else if (typeArgument instanceof GenericArrayType arrayType) {
|
||||
return (Byte.TYPE == arrayType.getGenericComponentType());
|
||||
return (byte.class == arrayType.getGenericComponentType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -230,7 +230,7 @@ class XStreamMarshallerTests {
|
||||
|
||||
@Test
|
||||
void useAttributesFor() throws Exception {
|
||||
marshaller.setUseAttributeForTypes(Long.TYPE);
|
||||
marshaller.setUseAttributeForTypes(long.class);
|
||||
Writer writer = new StringWriter();
|
||||
marshaller.marshal(flight, new StreamResult(writer));
|
||||
String expected = "<flight flightNumber=\"42\" />";
|
||||
@@ -239,7 +239,7 @@ class XStreamMarshallerTests {
|
||||
|
||||
@Test
|
||||
void useAttributesForStringClassMap() throws Exception {
|
||||
marshaller.setUseAttributeFor(Collections.singletonMap("flightNumber", Long.TYPE));
|
||||
marshaller.setUseAttributeFor(Collections.singletonMap("flightNumber", long.class));
|
||||
Writer writer = new StringWriter();
|
||||
marshaller.marshal(flight, new StreamResult(writer));
|
||||
String expected = "<flight flightNumber=\"42\" />";
|
||||
|
||||
Reference in New Issue
Block a user