/* LanguageTool, a natural language style checker
 * Copyright (C) 2013 Daniel Naber (http://www.danielnaber.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.rules.patterns;

/**
 * A {@link PatternRule}'s id with an optional sub-id.
 */
public class PatternRuleId {

  private final String id;
  private final String subId;

  /**
   * @param id the rule id
   */
  public PatternRuleId(String id) {
    this.id = id;
    this.subId = null;
  }

  /**
   * @param id the rule id
   * @param subId the sub id of a rulegroup, starting at {@code 1}
   */
  public PatternRuleId(String id, String subId) {
    this.id = id;
    this.subId = subId;
  }

  public String getId() {
    return id;
  }

  /**
   * @return a sub id or {@code null} if no sub id has been set
   */
  public String getSubId() {
    return subId;
  }

  @Override
  public String toString() {
    return id + "/" + subId;
  }

}

@@ -894,16 +894,58 @@
 terns;%0A%0A
+import org.apache.commons.lang.Validate;%0A%0A
 /**%0A * A
@@ -1158,24 +1158,69 @@
 tring id) %7B%0A
+    Validate.notEmpty(id, %22id must be set%22);%0A
     this.id 
@@ -1405,24 +1405,134 @@
 ng subId) %7B%0A
+    Validate.notEmpty(id, %22id must be set%22);%0A    Validate.notEmpty(subId, %22subId must be set, if specified%22);%0A
     this.id 
@@ -1777,24 +1777,51 @@
 oString() %7B%0A
+    if (subId != null) %7B%0A  
     return i
@@ -1833,19 +1833,55 @@
 /%22 + subId;%0A
+    %7D else %7B%0A      return id;%0A    %7D%0A
   %7D%0A%0A%7D%0A

fix toString(), validate parameters