Exemplo n.º 1
0
  public boolean isParent(NodePath path) {
    if (size() >= path.size()) return false;

    for (int i = 0; i < size(); i++) {
      String name = getSegment(i);
      if (!name.equals(path.getSegment(i))) {
        return false;
      }
    }

    return true;
  }
Exemplo n.º 2
0
  @Override
  public int compareTo(NodePath other) {
    int size = size();
    int otherSize = other.size();

    for (int i = 0; i < otherSize; i++) {
      if (i >= size) break;

      int result = getSegment(i).compareTo(other.getSegment(i));
      if (result != 0) return result;
    }

    return (size < otherSize ? -1 : (size == otherSize ? 0 : 1));
  }