#1948 Fix minor warnings with using collection in package model and class util/workarounds/EclipseAsMemberOfWorkaround (#1949)

This commit is contained in:
Andrei Arlou 2019-10-20 14:16:26 +03:00 committed by GitHub
parent fe37b01c65
commit e8a7832d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 25 deletions

View File

@ -8,7 +8,6 @@ package org.mapstruct.ap.internal.model;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@ -371,11 +370,8 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
);
}
else {
Collections.sort(
propertyMappings,
Comparator.comparingInt( propertyMapping ->
graphAnalyzer.getTraversalSequence( propertyMapping.getName() ) )
);
propertyMappings.sort( Comparator.comparingInt( propertyMapping ->
graphAnalyzer.getTraversalSequence( propertyMapping.getName() ) ) );
}
}

View File

@ -80,17 +80,11 @@ public class LifecycleCallbackMethodReference extends MethodReference {
@Override
public Set<Type> getImportTypes() {
return declaringType != null ? Collections.asSet( declaringType ) : java.util.Collections.<Type> emptySet();
return declaringType != null ? Collections.asSet( declaringType ) : java.util.Collections.emptySet();
}
public boolean hasMappingTargetParameter() {
for ( ParameterBinding param : getParameterBindings() ) {
if ( param.isMappingTarget() ) {
return true;
}
}
return false;
return getParameterBindings().stream().anyMatch( ParameterBinding::isMappingTarget );
}
/**

View File

@ -76,7 +76,7 @@ public class ObjectFactoryMethodResolver {
selectors.getMatchingMethods(
method,
getAllAvailableMethods( method, ctx.getSourceModel() ),
java.util.Collections.<Type> emptyList(),
java.util.Collections.emptyList(),
alternativeTarget,
SelectionCriteria.forFactoryMethods( selectionParameters ) );

View File

@ -23,7 +23,7 @@ import org.mapstruct.ap.internal.model.common.Parameter;
*/
public class ParameterProvidedMethods {
private static final ParameterProvidedMethods EMPTY =
new ParameterProvidedMethods( Collections.<Parameter, List<SourceMethod>> emptyMap() );
new ParameterProvidedMethods( Collections.emptyMap() );
private final Map<Parameter, List<SourceMethod>> parameterToProvidedMethods;
private final Map<SourceMethod, Parameter> methodToProvidingParameter;

View File

@ -454,13 +454,7 @@ public class SourceMethod implements Method {
* @return {@code true} if the parameter list contains a parameter annotated with {@code @TargetType}
*/
public static boolean containsTargetTypeParameter(List<Parameter> parameters) {
for ( Parameter param : parameters ) {
if ( param.isTargetType() ) {
return true;
}
}
return false;
return parameters.stream().anyMatch( Parameter::isTargetType );
}
@Override

View File

@ -6,7 +6,6 @@
package org.mapstruct.ap.internal.util.workarounds;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
@ -73,7 +72,7 @@ final class EclipseAsMemberOfWorkaround {
candidatesFromInterfaces );
// there can be multiple matches for the same method name from adjacent interface hierarchies.
Collections.sort( candidatesFromInterfaces, MostSpecificMethodBindingComparator.INSTANCE );
candidatesFromInterfaces.sort( MostSpecificMethodBindingComparator.INSTANCE );
if ( !candidatesFromInterfaces.isEmpty() ) {
// return the most specific match