public static String buildSelectorFromElementsAndAttribute(Collection<String> elementNameList,@Nullable String attributeName,boolean notEmptyAttribute){
  StringBuilder selector=new StringBuilder();
  boolean isFirstElement=true;
  for (  String elementName : elementNameList) {
    if (!isFirstElement) {
      selector.append(SPACE);
      selector.append(COMMA);
      selector.append(SPACE);
    }
    selector.append(elementName);
    if (StringUtils.isNotBlank(attributeName)) {
      selector.append(OPEN_BRACKET);
      selector.append(attributeName);
      selector.append(CLOSE_BRACKET);
      if (notEmptyAttribute) {
        selector.append(NOT_PREFIX);
        selector.append(OPEN_BRACKET);
        selector.append(attributeName);
        selector.append(NOT_EMPTY_REGEXP);
        selector.append(CLOSE_BRACKET);
        selector.append(CLOSE_PARENTHESE);
      }
    }
    isFirstElement=false;
  }
  return selector.toString();
}

public static String buildSelectorFromElementsAndAttribute ( Collection < String > elementNameList , @ Nullable String attributeName , boolean notEmptyAttribute ) { StringBuilder selector = new StringBuilder ( ) ; boolean isFirstElement = true ; for ( String elementName : elementNameList ) { if ( ! isFirstElement ) { selector . append ( SPACE ) ; selector . append ( COMMA ) ; selector . append ( SPACE ) ; } selector . append ( elementName ) ; if ( StringUtils . isNotBlank ( attributeName ) ) { selector . append ( OPEN_BRACKET ) ; selector . append ( attributeName ) ; selector . append ( CLOSE_BRACKET ) ; if ( notEmptyAttribute ) { selector . append ( NOT_PREFIX ) ; selector . append ( OPEN_BRACKET ) ; selector . append ( attributeName ) ; selector . append ( NOT_EMPTY_REGEXP ) ; selector . append ( CLOSE_BRACKET ) ; selector . append ( CLOSE_PARENTHESE ) ; } } isFirstElement = false ; } return selector . toString ( ) ; }
build a jquery selector to retrieve elements that contain a given attribute . the notemptyattribute attribute determines whether this attribute can be empty or not
