GoogleCloudStorageStrings { public static String matchListPrefix( String objectNamePrefix, String objectName, ListObjectOptions listOptions) { checkArgument( !isNullOrEmpty(objectName), "matchListPrefix(%s, %s, %s): objectName must not be null or empty.", objectNamePrefix, objectName, listOptions); String suffix = objectName; int suffixIndex = 0; if (objectNamePrefix != null) { if (!objectName.startsWith(objectNamePrefix) || (objectName.equals(objectNamePrefix) && objectNamePrefix.endsWith(PATH_DELIMITER) && !listOptions.isIncludePrefix())) { return null; } suffixIndex = objectNamePrefix.length(); suffix = objectName.substring(suffixIndex); } String delimiter = listOptions.getDelimiter(); return !isNullOrEmpty(delimiter) && suffix.contains(delimiter) ? objectName.substring(0, objectName.indexOf(delimiter, suffixIndex) + delimiter.length()) : objectName; }  static String matchListPrefix(
      String objectNamePrefix, String objectName, ListObjectOptions listOptions);  }
@Test public void testMatchListPrefixIllegalArguments() { String[][] invalidArgs = { {"my-prefix", null}, {"my-prefix", ""}, {null, null}, {null, ""}, }; for (String[] args : invalidArgs) { IllegalArgumentException iae = assertThrows( IllegalArgumentException.class, () -> GoogleCloudStorageStrings.matchListPrefix( args[0], args[1], ListObjectOptions.DEFAULT)); assertThat(iae).hasMessageThat().matches(".*objectName.*"); } }