Example #1
0
  /**
   * Converts the path spec to its short hand form. It minimises the output by matching elminating
   * settings that match either the path or in-built defaults.
   */
  public String toShortHand(RepoPath path) {
    Assert.isTrue(
        path.getId().equals(to),
        "Attempt to create shorthand with the wrong path: to=" + to + ", path=" + path.getId());

    StringBuffer sb = new StringBuffer(to);

    if (mandatory.booleanValue() != path.isMandatoryDefault()) {
      sb.append(mandatory.booleanValue() ? "!" : "?");
    }

    if (descend.booleanValue() != path.isDescendDefault()) {
      sb.append(descend.booleanValue() ? "<" : "+");
    }

    if (!from.equals(RUNTIME)) {
      sb.append((descend.booleanValue() == path.isDescendDefault()) ? "=" : "");
      sb.append(from);
    }

    sb.append((options == null) ? "" : ("(" + options + ")"));

    return sb.toString();
  }