@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2002 - 2022 the original author or authors .
* Copyright 2002 - 2023 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -228,7 +228,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
int attributeIndex = getAttributeIndex ( attributeName , true ) ;
int attributeIndex = getAttributeIndex ( attributeName , true ) ;
Method attribute = this . mapping . getAttributes ( ) . get ( attributeIndex ) ;
Method attribute = this . mapping . getAttributes ( ) . get ( attributeIndex ) ;
Class < ? > componentType = attribute . getReturnType ( ) . getC omponentType( ) ;
Class < ? > componentType = attribute . getReturnType ( ) . c omponentType( ) ;
Assert . notNull ( type , "Type must not be null" ) ;
Assert . notNull ( type , "Type must not be null" ) ;
Assert . notNull ( componentType , ( ) - > "Attribute " + attributeName + " is not an array" ) ;
Assert . notNull ( componentType , ( ) - > "Attribute " + attributeName + " is not an array" ) ;
Assert . isAssignable ( type , componentType , ( ) - > "Attribute " + attributeName + " component type mismatch:" ) ;
Assert . isAssignable ( type , componentType , ( ) - > "Attribute " + attributeName + " component type mismatch:" ) ;
@ -286,7 +286,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
private Class < ? > getTypeForMapOptions ( Method attribute , Adapt [ ] adaptations ) {
private Class < ? > getTypeForMapOptions ( Method attribute , Adapt [ ] adaptations ) {
Class < ? > attributeType = attribute . getReturnType ( ) ;
Class < ? > attributeType = attribute . getReturnType ( ) ;
Class < ? > componentType = ( attributeType . isArray ( ) ? attributeType . getC omponentType( ) : attributeType ) ;
Class < ? > componentType = ( attributeType . isArray ( ) ? attributeType . c omponentType( ) : attributeType ) ;
if ( Adapt . CLASS_TO_STRING . isIn ( adaptations ) & & componentType = = Class . class ) {
if ( Adapt . CLASS_TO_STRING . isIn ( adaptations ) & & componentType = = Class . class ) {
return ( attributeType . isArray ( ) ? String [ ] . class : String . class ) ;
return ( attributeType . isArray ( ) ? String [ ] . class : String . class ) ;
}
}
@ -309,7 +309,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
return result ;
return result ;
}
}
Object result = Array . newInstance (
Object result = Array . newInstance (
attribute . getReturnType ( ) . getC omponentType( ) , annotations . length ) ;
attribute . getReturnType ( ) . c omponentType( ) , annotations . length ) ;
for ( int i = 0 ; i < annotations . length ; i + + ) {
for ( int i = 0 ; i < annotations . length ; i + + ) {
Array . set ( result , i , annotations [ i ] . synthesize ( ) ) ;
Array . set ( result , i , annotations [ i ] . synthesize ( ) ) ;
}
}
@ -470,8 +470,8 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
value = annotation . synthesize ( ) ;
value = annotation . synthesize ( ) ;
}
}
else if ( value instanceof MergedAnnotation < ? > [ ] annotations & &
else if ( value instanceof MergedAnnotation < ? > [ ] annotations & &
type . isArray ( ) & & type . getC omponentType( ) . isAnnotation ( ) ) {
type . isArray ( ) & & type . c omponentType( ) . isAnnotation ( ) ) {
Object array = Array . newInstance ( type . getC omponentType( ) , annotations . length ) ;
Object array = Array . newInstance ( type . c omponentType( ) , annotations . length ) ;
for ( int i = 0 ; i < annotations . length ; i + + ) {
for ( int i = 0 ; i < annotations . length ; i + + ) {
Array . set ( array , i , annotations [ i ] . synthesize ( ) ) ;
Array . set ( array , i , annotations [ i ] . synthesize ( ) ) ;
}
}
@ -495,11 +495,11 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
if ( attributeType . isAnnotation ( ) ) {
if ( attributeType . isAnnotation ( ) ) {
return adaptToMergedAnnotation ( value , ( Class < ? extends Annotation > ) attributeType ) ;
return adaptToMergedAnnotation ( value , ( Class < ? extends Annotation > ) attributeType ) ;
}
}
if ( attributeType . isArray ( ) & & attributeType . getC omponentType( ) . isAnnotation ( ) ) {
if ( attributeType . isArray ( ) & & attributeType . c omponentType( ) . isAnnotation ( ) ) {
MergedAnnotation < ? > [ ] result = new MergedAnnotation < ? > [ Array . getLength ( value ) ] ;
MergedAnnotation < ? > [ ] result = new MergedAnnotation < ? > [ Array . getLength ( value ) ] ;
for ( int i = 0 ; i < result . length ; i + + ) {
for ( int i = 0 ; i < result . length ; i + + ) {
result [ i ] = adaptToMergedAnnotation ( Array . get ( value , i ) ,
result [ i ] = adaptToMergedAnnotation ( Array . get ( value , i ) ,
( Class < ? extends Annotation > ) attributeType . getC omponentType( ) ) ;
( Class < ? extends Annotation > ) attributeType . c omponentType( ) ) ;
}
}
return result ;
return result ;
}
}
@ -510,7 +510,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
return value ;
return value ;
}
}
if ( attributeType . isArray ( ) & & isEmptyObjectArray ( value ) ) {
if ( attributeType . isArray ( ) & & isEmptyObjectArray ( value ) ) {
return emptyArray ( attributeType . getC omponentType( ) ) ;
return emptyArray ( attributeType . c omponentType( ) ) ;
}
}
if ( ! attributeType . isInstance ( value ) ) {
if ( ! attributeType . isInstance ( value ) ) {
throw new IllegalStateException ( "Attribute '" + attribute . getName ( ) +
throw new IllegalStateException ( "Attribute '" + attribute . getName ( ) +
@ -561,7 +561,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
if ( attributeType . isAnnotation ( ) ) {
if ( attributeType . isAnnotation ( ) ) {
return ( Class < T > ) MergedAnnotation . class ;
return ( Class < T > ) MergedAnnotation . class ;
}
}
if ( attributeType . isArray ( ) & & attributeType . getC omponentType( ) . isAnnotation ( ) ) {
if ( attributeType . isArray ( ) & & attributeType . c omponentType( ) . isAnnotation ( ) ) {
return ( Class < T > ) MergedAnnotation [ ] . class ;
return ( Class < T > ) MergedAnnotation [ ] . class ;
}
}
return ( Class < T > ) ClassUtils . resolvePrimitiveIfNecessary ( attributeType ) ;
return ( Class < T > ) ClassUtils . resolvePrimitiveIfNecessary ( attributeType ) ;