private Lock getSingleLockFromString()

in server/src/jetbrains/buildServer/sharedResources/server/feature/LocksImpl.java [117:142]


  private Lock getSingleLockFromString(@NotNull final String str) {
    // get location of Type
    int t = -1; // position of type
    LockType type = null;
    for (LockType lockType: LockType.values()) {
      t = str.lastIndexOf(lockType.getName());
      if (t > 0) {
        type = lockType;
        break;
      }
    }
    Lock result = null;
    if (type != null) {
      final String name = str.substring(0, t).trim();
      int m = str.indexOf(' ', t + 1);
      // lock is valid
      if (m > 0) {
        // values
        result = new Lock(name, type, str.substring(m + 1).trim());
      } else {
        // no values
        result = new Lock(name, type);
      }
    }
    return result;
  }