package jauter;

public class Pattern<T> {
  protected final String   path;
  protected final String[] tokens;
  protected final T        target;

  public static String removeSlashAtBothEnds(String path) {
    if (path.isEmpty()) return path;

    int beginIndex = 0;
    while (beginIndex < path.length() && path.charAt(beginIndex) == '/') beginIndex++;
    if (beginIndex == path.length()) return "";

    int endIndex = path.length() - 1;
    while (endIndex > beginIndex && path.charAt(endIndex) == '/') endIndex--;

    return path.substring(beginIndex, endIndex + 1);
  }

  public Pattern(String path, T target) {
    this.path   = removeSlashAtBothEnds(path);
    this.tokens = this.path.split("/");
    this.target = target;
  }

  public String path() {
    return path;
  }

  public String[] tokens() {
    return tokens;
  }

  public T target() {
    return target;
  }
}

@@ -36,31 +36,29 @@
 rn%3CT%3E %7B%0A  pr
-otec
+iva
 te
-d
  final Strin
@@ -67,31 +67,29 @@
   path;%0A  pr
-otec
+iva
 te
-d
  final Strin
@@ -108,15 +108,13 @@
   pr
-otec
+iva
 te
-d
  fin

Use "private" for fields in struct-like classes