package org.codeswarm.lipsum;

class PrefixTemplateNames implements STGroupParagraphGenerator.TemplateNames {

  private final String prefix;
  private final int minIndex;
  private final int maxIndex;

  PrefixTemplateNames(String prefix, int minIndex, int maxIndex) {
    if (minIndex < 0) throw new IllegalArgumentException("minIndex must be >= 0");
    if (minIndex > maxIndex) throw new IllegalArgumentException("maxIndex >= minIndex");
    this.prefix = prefix;
    this.minIndex = minIndex;
    this.maxIndex = maxIndex;
  }

  @Override
  public int getMinIndex() {
    return minIndex;
  }

  @Override
  public int getMaxIndex() {
    return maxIndex;
  }

  @Override
  public String getTemplateName(int index) {
    return prefix + Integer.toString(index);
  }

}

@@ -24,16 +24,62 @@
 ipsum;%0A%0A
+import com.google.common.base.Preconditions;%0A%0A
 class Pr
@@ -317,62 +317,36 @@
     
-if (minIndex %3C 0) throw new IllegalArgumentException(%22
+Preconditions.checkArgument(
 minI
@@ -354,110 +354,67 @@
 dex 
-must be 
 %3E= 0
-%22
 );%0A    
-if (minIndex %3E maxIndex) throw new IllegalArgumentException(%22max
+Preconditions.checkArgument(min
 Index 
-%3E= min
+%3C= max
 Index
-%22
 );%0A 

Use guava Preconditions to check arguments.