mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
This commit is contained in:
parent
f95648cef8
commit
7af107c9f2
@ -380,7 +380,7 @@ public class TypeFactory {
|
||||
Iterator<? extends VariableElement> varIt = parameters.iterator();
|
||||
Iterator<? extends TypeMirror> typesIt = parameterTypes.iterator();
|
||||
|
||||
for ( ; varIt.hasNext(); ) {
|
||||
while ( varIt.hasNext() ) {
|
||||
VariableElement parameter = varIt.next();
|
||||
TypeMirror parameterType = typesIt.next();
|
||||
|
||||
@ -549,38 +549,6 @@ public class TypeFactory {
|
||||
return arrayType.getComponentType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts any collection type, e.g. {@code List<T>} to {@code Collection<T>} and any map type, e.g.
|
||||
* {@code HashMap<K,V>} to {@code Map<K,V>}.
|
||||
*
|
||||
* @param collectionOrMap any collection or map type
|
||||
* @return the type representing {@code Collection<T>} or {@code Map<K,V>}, if the argument type is a subtype of
|
||||
* {@code Collection<T>} or of {@code Map<K,V>} respectively.
|
||||
*/
|
||||
public Type asCollectionOrMap(Type collectionOrMap) {
|
||||
List<Type> originalParameters = collectionOrMap.getTypeParameters();
|
||||
TypeMirror[] originalParameterMirrors = new TypeMirror[originalParameters.size()];
|
||||
int i = 0;
|
||||
for ( Type param : originalParameters ) {
|
||||
originalParameterMirrors[i++] = param.getTypeMirror();
|
||||
}
|
||||
|
||||
if ( collectionOrMap.isCollectionType()
|
||||
&& !"java.util.Collection".equals( collectionOrMap.getFullyQualifiedName() ) ) {
|
||||
return getType( typeUtils.getDeclaredType(
|
||||
elementUtils.getTypeElement( "java.util.Collection" ),
|
||||
originalParameterMirrors ) );
|
||||
}
|
||||
else if ( collectionOrMap.isMapType()
|
||||
&& !"java.util.Map".equals( collectionOrMap.getFullyQualifiedName() ) ) {
|
||||
return getType( typeUtils.getDeclaredType(
|
||||
elementUtils.getTypeElement( "java.util.Map" ),
|
||||
originalParameterMirrors ) );
|
||||
}
|
||||
|
||||
return collectionOrMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a void return type
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user