public static void addOrUpdateKeywordSet(List<KeywordSet> keywords,String keyword,String thesaurus){
  if (!Strings.isNullOrEmpty(keyword) && !Strings.isNullOrEmpty(thesaurus)) {
    String capped=StringUtils.capitalize(keyword.toLowerCase());
    boolean found=false;
    for (    KeywordSet ks : keywords) {
      String keywordThesaurus=ks.getKeywordThesaurus();
      if (!Strings.isNullOrEmpty(keywordThesaurus) && keywordThesaurus.equalsIgnoreCase(thesaurus)) {
        String keywordString=ks.getKeywordsString();
        if (Strings.isNullOrEmpty(keywordString)) {
          ks.setKeywordsString(capped);
        }
        found=true;
        break;
      }
    }
    if (!found) {
      KeywordSet ks=new KeywordSet();
      ks.setKeywordThesaurus(thesaurus);
      ks.setKeywordsString(capped);
      keywords.add(ks);
    }
  }
}

public static void addOrUpdateKeywordSet ( List < KeywordSet > keywords , String keyword , String thesaurus ) { if ( ! Strings . isNullOrEmpty ( keyword ) && ! Strings . isNullOrEmpty ( thesaurus ) ) { String capped = StringUtils . capitalize ( keyword . toLowerCase ( ) ) ; boolean found = false ; for ( KeywordSet ks : keywords ) { String keywordThesaurus = ks . getKeywordThesaurus ( ) ; if ( ! Strings . isNullOrEmpty ( keywordThesaurus ) && keywordThesaurus . equalsIgnoreCase ( thesaurus ) ) { String keywordString = ks . getKeywordsString ( ) ; if ( Strings . isNullOrEmpty ( keywordString ) ) { ks . setKeywordsString ( capped ) ; } found = true ; break ; } } if ( ! found ) { KeywordSet ks = new KeywordSet ( ) ; ks . setKeywordThesaurus ( thesaurus ) ; ks . setKeywordsString ( capped ) ; keywords . add ( ks ) ; } } }
add or update keywordset identified by thesaurus name . if the keywordset is found and already contains a a non empty and not null keywordstring , its value is not overwritten .
