/**
   * Set the styles which should be cached on a layer
   *
   * @param info
   * @param defaultStyle
   * @param cachedStyles
   */
  public static void setCachedStyles(
      GeoServerTileLayerInfo info, String defaultStyle, Set<String> cachedStyles) {
    StyleParameterFilter filter = (StyleParameterFilter) info.getParameterFilter("STYLES");
    if (filter == null) filter = new StyleParameterFilter();

    filter.setDefaultValue(defaultStyle);
    filter.setStyles(cachedStyles);
    info.addParameterFilter(filter);
  }
  /**
   * If the layer is configured for automatic style updates of its Style parameter filter, do so.
   *
   * @param layer The GeoServer layer
   * @param layerInfo The GeoWebCache layer
   */
  public static void checkAutomaticStyles(final LayerInfo layer, GeoServerTileLayerInfo layerInfo) {

    ParameterFilter filter = layerInfo.getParameterFilter("STYLES");

    // Update the filter with the latest available styles if it's a style filter
    if (filter != null && filter instanceof StyleParameterFilter) {
      ((StyleParameterFilter) filter).setLayer(layer);
    }
  }
  /**
   * If the layer is configured for automatic style updates of its Style parameter filter, do so.
   *
   * @param layer The GeoServer layer group
   * @param layerInfo The GeoWebCache layer
   */
  public static void checkAutomaticStyles(
      final LayerGroupInfo layer, GeoServerTileLayerInfo layerInfo) {

    ParameterFilter filter = layerInfo.getParameterFilter("STYLES");

    // Remove the filter as groups shouldn't have auto-updating styles
    if (filter != null && filter instanceof StyleParameterFilter) {
      layerInfo.removeParameterFilter("STYLES");
    }
  }