[MNG-7271] - Code Improvement

This commit is contained in:
Karl Heinz Marbaise 2021-09-29 22:23:32 +02:00
parent c8d5ba3705
commit 25cf1576cc
No known key found for this signature in database
GPG Key ID: BF1518E0160788A2
1 changed files with 5 additions and 17 deletions

View File

@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.execution.ProjectDependencyGraph;
import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.DuplicateProjectException;
@ -166,15 +167,10 @@ public class DefaultProjectDependencyGraph
private List<MavenProject> getSortedProjects( Set<String> projectIds ) private List<MavenProject> getSortedProjects( Set<String> projectIds )
{ {
List<MavenProject> result = new ArrayList<>( projectIds.size() ); return projectIds.stream()
for ( String projectId : projectIds ) .map( id -> projects.get( id ) )
{ .sorted( Comparator.comparingInt( order::get ) )
result.add( projects.get( projectId ) ); .collect( Collectors.toList() );
}
Collections.sort( result, new MavenProjectComparator() );
return result;
} }
@Override @Override
@ -183,12 +179,4 @@ public class DefaultProjectDependencyGraph
return sorter.getSortedProjects().toString(); return sorter.getSortedProjects().toString();
} }
private class MavenProjectComparator implements Comparator<MavenProject>
{
@Override
public int compare( MavenProject o1, MavenProject o2 )
{
return order.get( o1 ) - order.get( o2 );
}
}
} }