code: private static String concatOverrides(String annotation, Collection<String> attributeOverrides) {
          if (attributeOverrides == null || attributeOverrides.size() < 1) {
              return annotation;
          }
          if (annotation == null) {
              annotation = "";
          }
          else {
              Matcher overrideMatcher;
              while ((overrideMatcher = PATTERN_ATTR_OVERRIDE.matcher(annotation)).find()) {
                  if (!(attributeOverrides instanceof ArrayList)) {
                      attributeOverrides = new ArrayList<String>(attributeOverrides);
                  }
                  ((ArrayList) attributeOverrides).add(0, overrideMatcher.group(1));
                  annotation = annotation.substring(0, overrideMatcher.start()) + annotation.substring(overrideMatcher.end());
              }
          }
  
          Matcher overridesMatcher = PATTERN_ATTR_OVERRIDES.matcher(annotation);
  
          if (!overridesMatcher.find()) {
              annotation = (annotation.length() < 1 ? "" : annotation + "\n    ") + "@" + AttributeOverrides.class.getName() + "({})";
          }
  
          for (String addOverride : attributeOverrides) {
              overridesMatcher = PATTERN_ATTR_OVERRIDES.matcher(annotation);
              if (!overridesMatcher.find()) {
                  throw new IllegalStateException();
              }
              if (StringUtils.isNotEmpty(overridesMatcher.group(2))) {
                  addOverride = ", " + addOverride;
              }
              annotation = annotation.substring(0, overridesMatcher.start(3)) + addOverride +
                      annotation.substring(overridesMatcher.start(3));
          }
  
          return annotation;
      }
docs: merges given collection of javax.persistence.AttributeOverride elements into an optionally existing
  javax.persistence.AttributeOverrides annotation with optionally pre-existing javax.persistence.AttributeOverride elements.
  
  @param annotation existing javax.persistence.AttributeOverrides annotation, if any, otherwise it will be created
  @param attributeOverrides collection of javax.persistence.AttributeOverride annotation to be appended
  @return merged AttributeOverrides annotation