View Javadoc
1   package com.atlassian.plugin.util;
2   
3   /**
4    * String utility methods designed for memory / cpu efficiency
5    */
6   public class EfficientStringUtils {
7       /**
8        * Test to see if a given string ends with some suffixes. Avoids the cost
9        * of concatenating the suffixes together
10       *
11       * @param src      the source string to be tested
12       * @param suffixes the set of suffixes
13       * @return true if src ends with the suffixes concatenated together
14       */
15      public static boolean endsWith(final String src, final String... suffixes) {
16          int pos = src.length();
17  
18          for (int i = suffixes.length - 1; i >= 0; i--) {
19              final String suffix = suffixes[i];
20              pos -= suffix.length();
21              if (!src.startsWith(suffix, pos)) {
22                  return false;
23              }
24          }
25          return true;
26      }
27  }