/**
   * Creates a single Style from the passed in styles. The passed in List is reverse sorted, that is
   * the most recently added style found to match will be first.
   */
  private SynthStyle mergeStyles(java.util.List styles) {
    int size = styles.size();

    if (size == 0) {
      return null;
    } else if (size == 1) {
      return (SynthStyle) ((DefaultSynthStyle) styles.get(0)).clone();
    }
    // NOTE: merging is done backwards as DefaultSynthStyleFactory reverses
    // order, that is, the most specific style is first.
    DefaultSynthStyle style = (DefaultSynthStyle) styles.get(size - 1);

    style = (DefaultSynthStyle) style.clone();
    for (int counter = size - 2; counter >= 0; counter--) {
      style = ((DefaultSynthStyle) styles.get(counter)).addTo(style);
    }
    return style;
  }
  /**
   * Returns an empty processor iterator if no processors are on the relevant path, otherwise if
   * processors are present, logs an error. Called when a service loader is unavailable for some
   * reason, either because a service loader class cannot be found or because a security policy
   * prevents class loaders from being created.
   *
   * @param key The resource key to use to log an error message
   * @param e If non-null, pass this exception to Abort
   */
  private Iterator<Processor> handleServiceLoaderUnavailability(String key, Exception e) {
    JavaFileManager fileManager = context.get(JavaFileManager.class);

    if (fileManager instanceof JavacFileManager) {
      StandardJavaFileManager standardFileManager = (JavacFileManager) fileManager;
      Iterable<? extends File> workingPath =
          fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
              ? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH)
              : standardFileManager.getLocation(CLASS_PATH);

      if (needClassLoader(options.get(PROCESSOR), workingPath)) handleException(key, e);

    } else {
      handleException(key, e);
    }

    java.util.List<Processor> pl = Collections.emptyList();
    return pl.iterator();
  }
  /** Fetches any styles that match the passed into arguments into <code>matches</code>. */
  private void getMatchingStyles(java.util.List matches, JComponent c, Region id) {
    String idName = id.getLowerCaseName();
    String cName = c.getName();

    if (cName == null) {
      cName = "";
    }
    for (int counter = _styles.size() - 1; counter >= 0; counter--) {
      StyleAssociation sa = _styles.get(counter);
      String path;

      if (sa.getID() == NAME) {
        path = cName;
      } else {
        path = idName;
      }

      if (sa.matches(path) && matches.indexOf(sa.getStyle()) == -1) {
        matches.add(sa.getStyle());
      }
    }
  }
 /** Returns the cached style from the passed in arguments. */
 private SynthStyle getCachedStyle(java.util.List styles) {
   if (styles.size() == 0) {
     return null;
   }
   return (SynthStyle) _resolvedStyles.get(styles);
 }