@@ -816,7 +816,7 @@ else if ( inMatchScope && matchTargetRegex.matcher( path ).matches() )
816
816
{
817
817
if ( "groupId" .equals ( elementName ) )
818
818
{
819
- haveGroupId = groupId . equals ( pom .getElementText ().trim () );
819
+ haveGroupId = pom .getElementText ().trim (). equals ( groupId );
820
820
path = stack .pop ();
821
821
}
822
822
else if ( "artifactId" .equals ( elementName ) )
@@ -1539,12 +1539,14 @@ public static Map<String, Model> getChildModels( Map<String, Model> reactor, Str
1539
1539
*/
1540
1540
public static Model getModel ( Map <String , Model > reactor , String groupId , String artifactId )
1541
1541
{
1542
- Map .Entry <String , Model > entry = getModelEntry ( reactor , groupId , artifactId );
1543
- return entry == null ? null : entry .getValue ();
1542
+ return reactor .values ().stream ().filter (
1543
+ model -> ( groupId == null || groupId .equals ( getGroupId ( model ) ) ) && artifactId .equals (
1544
+ getArtifactId ( model ) ) ).findAny ().orElse ( null );
1544
1545
}
1545
1546
1546
1547
/**
1547
- * Returns the model that has the specified groupId and artifactId or <code>null</code> if no such model exists.
1548
+ * Returns the model that has the specified groupId (if specified)
1549
+ * and artifactId or <code>null</code> if no such model exists.
1548
1550
*
1549
1551
* @param reactor The map of models keyed by path.
1550
1552
* @param groupId The groupId to match.
@@ -1554,15 +1556,9 @@ public static Model getModel( Map<String, Model> reactor, String groupId, String
1554
1556
public static Map .Entry <String , Model > getModelEntry ( Map <String , Model > reactor , String groupId ,
1555
1557
String artifactId )
1556
1558
{
1557
- for ( Map .Entry <String , Model > entry : reactor .entrySet () )
1558
- {
1559
- Model model = entry .getValue ();
1560
- if ( groupId .equals ( getGroupId ( model ) ) && artifactId .equals ( getArtifactId ( model ) ) )
1561
- {
1562
- return entry ;
1563
- }
1564
- }
1565
- return null ;
1559
+ return reactor .entrySet ().stream ().filter (
1560
+ e -> ( groupId == null || groupId .equals ( PomHelper .getGroupId ( e .getValue () ) ) ) && artifactId .equals (
1561
+ PomHelper .getArtifactId ( e .getValue () ) ) ).findAny ().orElse ( null );
1566
1562
}
1567
1563
1568
1564
/**
@@ -1578,15 +1574,12 @@ public static int getReactorParentCount( Map<String, Model> reactor, Model model
1578
1574
{
1579
1575
return 0 ;
1580
1576
}
1581
- else
1577
+ Model parentModel = getModel ( reactor , model .getParent ().getGroupId (), model .getParent ().getArtifactId () );
1578
+ if ( parentModel == null )
1582
1579
{
1583
- Model parentModel = getModel ( reactor , model .getParent ().getGroupId (), model .getParent ().getArtifactId () );
1584
- if ( parentModel != null )
1585
- {
1586
- return getReactorParentCount ( reactor , parentModel ) + 1 ;
1587
- }
1588
1580
return 0 ;
1589
1581
}
1582
+ return getReactorParentCount ( reactor , parentModel ) + 1 ;
1590
1583
}
1591
1584
1592
1585
/**
0 commit comments