Skip to content

Commit e8a7832

Browse files
authored
mapstruct#1948 Fix minor warnings with using collection in package model and class util/workarounds/EclipseAsMemberOfWorkaround (mapstruct#1949)
1 parent fe37b01 commit e8a7832

6 files changed

Lines changed: 8 additions & 25 deletions

File tree

processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.text.MessageFormat;
99
import java.util.ArrayList;
1010
import java.util.Collection;
11-
import java.util.Collections;
1211
import java.util.Comparator;
1312
import java.util.HashMap;
1413
import java.util.HashSet;
@@ -371,11 +370,8 @@ private void sortPropertyMappingsByDependencies() {
371370
);
372371
}
373372
else {
374-
Collections.sort(
375-
propertyMappings,
376-
Comparator.comparingInt( propertyMapping ->
377-
graphAnalyzer.getTraversalSequence( propertyMapping.getName() ) )
378-
);
373+
propertyMappings.sort( Comparator.comparingInt( propertyMapping ->
374+
graphAnalyzer.getTraversalSequence( propertyMapping.getName() ) ) );
379375
}
380376
}
381377

processor/src/main/java/org/mapstruct/ap/internal/model/LifecycleCallbackMethodReference.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,11 @@ public String getTargetVariableName() {
8080

8181
@Override
8282
public Set<Type> getImportTypes() {
83-
return declaringType != null ? Collections.asSet( declaringType ) : java.util.Collections.<Type> emptySet();
83+
return declaringType != null ? Collections.asSet( declaringType ) : java.util.Collections.emptySet();
8484
}
8585

8686
public boolean hasMappingTargetParameter() {
87-
for ( ParameterBinding param : getParameterBindings() ) {
88-
if ( param.isMappingTarget() ) {
89-
return true;
90-
}
91-
}
92-
93-
return false;
87+
return getParameterBindings().stream().anyMatch( ParameterBinding::isMappingTarget );
9488
}
9589

9690
/**

processor/src/main/java/org/mapstruct/ap/internal/model/ObjectFactoryMethodResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static MethodReference getFactoryMethod( Method method,
7676
selectors.getMatchingMethods(
7777
method,
7878
getAllAvailableMethods( method, ctx.getSourceModel() ),
79-
java.util.Collections.<Type> emptyList(),
79+
java.util.Collections.emptyList(),
8080
alternativeTarget,
8181
SelectionCriteria.forFactoryMethods( selectionParameters ) );
8282

processor/src/main/java/org/mapstruct/ap/internal/model/source/ParameterProvidedMethods.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
public class ParameterProvidedMethods {
2525
private static final ParameterProvidedMethods EMPTY =
26-
new ParameterProvidedMethods( Collections.<Parameter, List<SourceMethod>> emptyMap() );
26+
new ParameterProvidedMethods( Collections.emptyMap() );
2727

2828
private final Map<Parameter, List<SourceMethod>> parameterToProvidedMethods;
2929
private final Map<SourceMethod, Parameter> methodToProvidingParameter;

processor/src/main/java/org/mapstruct/ap/internal/model/source/SourceMethod.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,7 @@ public boolean matches(List<Type> sourceTypes, Type targetType) {
454454
* @return {@code true} if the parameter list contains a parameter annotated with {@code @TargetType}
455455
*/
456456
public static boolean containsTargetTypeParameter(List<Parameter> parameters) {
457-
for ( Parameter param : parameters ) {
458-
if ( param.isTargetType() ) {
459-
return true;
460-
}
461-
}
462-
463-
return false;
457+
return parameters.stream().anyMatch( Parameter::isTargetType );
464458
}
465459

466460
@Override

processor/src/main/java/org/mapstruct/ap/internal/util/workarounds/EclipseAsMemberOfWorkaround.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package org.mapstruct.ap.internal.util.workarounds;
77

88
import java.util.ArrayList;
9-
import java.util.Collections;
109
import java.util.Comparator;
1110
import java.util.HashSet;
1211
import java.util.List;
@@ -73,7 +72,7 @@ static TypeMirror asMemberOf(ProcessingEnvironment environment, DeclaredType con
7372
candidatesFromInterfaces );
7473

7574
// there can be multiple matches for the same method name from adjacent interface hierarchies.
76-
Collections.sort( candidatesFromInterfaces, MostSpecificMethodBindingComparator.INSTANCE );
75+
candidatesFromInterfaces.sort( MostSpecificMethodBindingComparator.INSTANCE );
7776

7877
if ( !candidatesFromInterfaces.isEmpty() ) {
7978
// return the most specific match

0 commit comments

Comments
 (0)