Source:
public PageableResult search(RequestContext context) throws ResponseException { String source = context.getParameter("source"); String code = context.getParameter("code"); String name = context.getParameter("name"); String searchType = context.getParameter("searchType"); if(searchType!=null&&!SEARCH_TYPE_EQUALS.equals(searchType)&&!SEARCH_TYPE_STARTS_WITH.equals(searchType)){ throw new InvalidSearchException("Invalid searchType parameter"); } if (searchType == null) { searchType = "equals"; } if (searchType.equals(SEARCH_TYPE_EQUALS)) { ConceptSource conceptSource = conceptService.getConceptSourceByUuid(source); if (conceptSource == null) { conceptSource = conceptService.getConceptSourceByName(source); if (conceptSource == null) { return new EmptySearchResult(); } } if (code != null || name != null) { return searchEquals(context, code, name, conceptSource); } else { List<ConceptReferenceTerm> terms = conceptService.getConceptReferenceTerms(null, conceptSource, context.getStartIndex(), context.getLimit(), context.getIncludeAll()); int count = conceptService.getCountOfConceptReferenceTerms(null, conceptSource, context.getIncludeAll()); boolean hasMore = count > (context.getStartIndex() + context.getLimit()); return new AlreadyPaged<ConceptReferenceTerm>(context, terms, hasMore); } } else { List<ConceptSource> conceptSources = new ArrayList<ConceptSource>(); ConceptSource singleConceptSource = conceptService.getConceptSourceByUuid(source); if (singleConceptSource != null) { conceptSources.add(singleConceptSource); } else { List<ConceptSource> allConceptSources = conceptService.getAllConceptSources(); if (allConceptSources.size() == 0) { return new EmptySearchResult(); } else { for (ConceptSource conceptSource : allConceptSources) { if (conceptSource.getName().contains(source)) { conceptSources.add(conceptSource); } } } } return searchStartsWith(context, code, name, conceptSources); } }

Target:
public PageableResult search(RequestContext context) throws ResponseException { String source = context.getParameter("source"); String codeOrName = context.getParameter("codeOrName"); String searchType = context.getParameter("searchType"); if(searchType!=null&&!SEARCH_TYPE_EQUALS.equals(searchType)&&!SEARCH_TYPE_STARTS_WITH.equals(searchType)){ throw new InvalidSearchException("Invalid searchType parameter"); } if (searchType == null) { searchType = "equals"; } if (searchType.equals(SEARCH_TYPE_EQUALS)) { ConceptSource conceptSource = conceptService.getConceptSourceByUuid(source); if (conceptSource == null) { conceptSource = conceptService.getConceptSourceByName(source); if (conceptSource == null) { return new EmptySearchResult(); } } if (codeOrName != null) { return searchEquals(context, codeOrName, conceptSource); } else { List<ConceptReferenceTerm> terms = conceptService.getConceptReferenceTerms(null, conceptSource, context.getStartIndex(), context.getLimit(), context.getIncludeAll()); int count = conceptService.getCountOfConceptReferenceTerms(null, conceptSource, context.getIncludeAll()); boolean hasMore = count > (context.getStartIndex() + context.getLimit()); return new AlreadyPaged<ConceptReferenceTerm>(context, terms, hasMore); } } else if (searchType.equals(SEARCH_TYPE_STARTS_WITH)) { List<ConceptSource> conceptSources = new ArrayList<ConceptSource>(); ConceptSource singleConceptSource = conceptService.getConceptSourceByUuid(source); if (singleConceptSource != null) { conceptSources.add(singleConceptSource); } else { List<ConceptSource> allConceptSources = conceptService.getAllConceptSources(); if (allConceptSources.isEmpty()) { return new EmptySearchResult(); } else { for (ConceptSource conceptSource : allConceptSources) { if (conceptSource.getName().startsWith(source)) { conceptSources.add(conceptSource); } } } } return searchStartsWith(context, codeOrName, conceptSources); } else { throw new IllegalStateException("\"" + searchType + "\" doesn't fit searchType param requirements. Search type must be " + SEARCH_TYPE_EQUALS + " or " + SEARCH_TYPE_STARTS_WITH + "."); } }