code: private static int ordinalIndexOf(final String str, final String substr, final int ordinal, final boolean isLastIndex) {
          if (ordinal < 1) {
              throw new IllegalArgumentException("ordinal(" + ordinal + ") must be >= 1");
          }
  
          if (N.isNullOrEmpty(str) || N.isNullOrEmpty(substr) || substr.length() > str.length()) {
              return N.INDEX_NOT_FOUND;
          }
  
          int fromIndex = isLastIndex ? str.length() : 0;
  
          for (int found = 0; fromIndex >= 0;) {
              fromIndex = isLastIndex ? str.lastIndexOf(substr, fromIndex) : str.indexOf(substr, fromIndex);
  
              if (fromIndex < 0) {
                  return N.INDEX_NOT_FOUND;
              }
  
              if (++found >= ordinal) {
                  break;
              }
  
              fromIndex = isLastIndex ? (fromIndex - substr.length()) : (fromIndex + substr.length());
          }
  
          return fromIndex;
      }
docs: lastOrdinalIndexOf(String,String,int)