Source:
com.google.gerrit.server.permissions.PermissionCollection filter ( java.lang.Iterable < com.google.gerrit.server.project.SectionMatcher > matcherList , java.lang.String ref , com.google.gerrit.server.CurrentUser user ) { if ( com.google.gerrit.server.project.RefPattern.isRE ( ref ) ) { ref = com.google.gerrit.server.project.RefPattern.shortestExample ( ref ) ; } else if ( ref.endsWith ( "/*" ) ) { ref = ref.substring ( 0 , ( ( ref.length ( ) ) - 1 ) ) ; } java.util.Map < com.google.gerrit.common.data.AccessSection , com.google.gerrit.reviewdb.client.Project.NameKey > sectionToProject = new java.util.LinkedHashMap < > ( ) ; boolean perUser = com.google.gerrit.server.permissions.PermissionCollection.Factory.filterRefMatchingSections ( matcherList , ref , user , sectionToProject ) ; java.util.List < com.google.gerrit.common.data.AccessSection > sections = com.google.common.collect.Lists.newArrayList ( sectionToProject.keySet ( ) ) ; sorter.sort ( ref , sections ) ; java.util.Set < com.google.gerrit.server.permissions.PermissionCollection.SeenRule > seen = new java.util.HashSet < > ( ) ; java.util.Set < java.lang.String > exclusiveGroupPermissions = new java.util.HashSet < > ( ) ; java.util.HashMap < java.lang.String , java.util.List < com.google.gerrit.common.data.PermissionRule > > permissions = new java.util.HashMap < > ( ) ; java.util.HashMap < java.lang.String , java.util.List < com.google.gerrit.common.data.PermissionRule > > overridden = new java.util.HashMap < > ( ) ; java.util.Map < com.google.gerrit.common.data.PermissionRule , com.google.gerrit.server.permissions.ProjectRef > ruleProps = com.google.common.collect.Maps.newIdentityHashMap ( ) ; com.google.common.collect.ListMultimap < com.google.gerrit.reviewdb.client.Project.NameKey , java.lang.String > exclusivePermissionsByProject = com.google.common.collect.MultimapBuilder.hashKeys ( ) . arrayListValues ( ) . build ( ) ; for ( com.google.gerrit.common.data.AccessSection section : sections ) { com.google.gerrit.reviewdb.client.Project.NameKey project = sectionToProject.get ( section ) ; for ( com.google.gerrit.common.data.Permission permission : section.getPermissions ( ) ) { boolean exclusivePermissionExists = exclusiveGroupPermissions.contains ( permission.getName ( ) ) ; for ( com.google.gerrit.common.data.PermissionRule rule : permission.getRules ( ) ) { com.google.gerrit.server.permissions.PermissionCollection.SeenRule s = com.google.gerrit.server.permissions.PermissionCollection.SeenRule.create ( section , permission , rule ) ; boolean addRule ; if ( rule.isBlock ( ) ) { addRule = ! ( exclusivePermissionsByProject.containsEntry ( project , permission.getName ( ) ) ) ; } else { addRule = ( ( seen.add ( s ) ) && ( ! ( rule.isDeny ( ) ) ) ) && ( ! exclusivePermissionExists ) ; } java.util.HashMap < java.lang.String , java.util.List < com.google.gerrit.common.data.PermissionRule > > p = null ; if ( addRule ) { p = permissions ; } else if ( ( ! ( rule.isDeny ( ) ) ) && ( ! exclusivePermissionExists ) ) { p = overridden ; } if ( p != null ) { java.util.List < com.google.gerrit.common.data.PermissionRule > r = p.get ( permission.getName ( ) ) ; if ( r == null ) { r = new java.util.ArrayList < > ( 2 ) ; p.put ( permission.getName ( ) , r ) ; } r.add ( rule ) ; ruleProps.put ( rule , com.google.gerrit.server.permissions.ProjectRef.create ( project , section.getName ( ) ) ) ; } } if ( permission.getExclusiveGroup ( ) ) { exclusivePermissionsByProject.put ( project , permission.getName ( ) ) ; exclusiveGroupPermissions.add ( permission.getName ( ) ) ; } } } return new com.google.gerrit.server.permissions.PermissionCollection ( permissions , overridden , ruleProps , perUser ) ; }

Target:
java.util.List < com.google.gerrit.common.data.PermissionRule > getAllowRules ( java.lang.String perm ) { java.util.List < com.google.gerrit.common.data.PermissionRule > ps = rulesByPermission.get ( perm ) ; if ( ps == null ) { ps = calculateAllowRules ( perm ) ; rulesByPermission.put ( perm , ps ) ; } return ps ; }