code: public static Style rulesToStyle( List<Rule> rules, String name, boolean oneFeaturetypestylePerRule ) {
          Style namedStyle = StyleUtilities.sf.createStyle();
          if (!oneFeaturetypestylePerRule) {
              FeatureTypeStyle featureTypeStyle = StyleUtilities.sf.createFeatureTypeStyle();
              List<Rule> currentRules = featureTypeStyle.rules();
              for( int i = 0; i < rules.size(); i++ ) {
                  Rule rule = rules.get(i);
                  currentRules.add(rule);
              }
              namedStyle.featureTypeStyles().add(featureTypeStyle);
          } else {
              for( int i = 0; i < rules.size(); i++ ) {
                  FeatureTypeStyle featureTypeStyle = StyleUtilities.sf.createFeatureTypeStyle();
                  Rule rule = rules.get(i);
                  featureTypeStyle.rules().add(rule);
                  namedStyle.featureTypeStyles().add(featureTypeStyle);
              }
          }
          namedStyle.setName(name);
          return namedStyle;
      }
docs: Converts a list of {@link Rule}s to a {@link Style} with the given name.
  
  @param rules the list of rules.
  @param name the name of the new style.
  @param oneFeaturetypestylePerRule switch to create a {@link FeatureTypeStyle} per {@link Rule}.
  @return the new style created.