private Map<MemberType,Integer> computeSearchLimits(int limit,MemberType memberType){
  Map<MemberType,Integer> memberTypeToLimit=new HashMap<MemberType,Integer>();
  int limitPerPrincipalType=limit;
  if (memberType == MemberType.ALL) {
    limitPerPrincipalType=limit < 0 ? -1 : limit / (MemberType.values().length - 1);
    int solutionUserLimit=limitPerPrincipalType < 0 ? -1 : limitPerPrincipalType + (limit % (MemberType.values().length - 1));
    memberTypeToLimit.put(MemberType.USER,limitPerPrincipalType);
    memberTypeToLimit.put(MemberType.GROUP,limitPerPrincipalType);
    memberTypeToLimit.put(MemberType.SOLUTIONUSER,solutionUserLimit);
  }
 else {
    memberTypeToLimit.put(memberType,limit);
  }
  return memberTypeToLimit;
}

private Map < MemberType , Integer > computeSearchLimits ( int limit , MemberType memberType ) { Map < MemberType , Integer > memberTypeToLimit = new HashMap < MemberType , Integer > ( ) ; int limitPerPrincipalType = limit ; if ( memberType == MemberType . ALL ) { limitPerPrincipalType = limit < 0 ? - 1 : limit / ( MemberType . values ( ) . length - 1 ) ; int solutionUserLimit = limitPerPrincipalType < 0 ? - 1 : limitPerPrincipalType + ( limit % ( MemberType . values ( ) . length - 1 ) ) ; memberTypeToLimit . put ( MemberType . USER , limitPerPrincipalType ) ; memberTypeToLimit . put ( MemberType . GROUP , limitPerPrincipalType ) ; memberTypeToLimit . put ( MemberType . SOLUTIONUSER , solutionUserLimit ) ; } else { memberTypeToLimit . put ( memberType , limit ) ; } return memberTypeToLimit ; }
search limit calculator that computes number of principal entities ( users , groups and solution users ) to be returned in search results
