HadoopConfigurationProperty { public Collection<String> getStringCollection(Configuration config) { checkState( defaultValue == null || defaultValue instanceof Collection, "Not a collection property"); String lookupKey = getLookupKey(config, key, deprecatedKeys, (c, k) -> c.get(k) != null); String valueString = config.get( lookupKey, defaultValue == null ? null : COMMA_JOINER.join((Collection<?>) defaultValue)); List<String> value = COMMA_SPLITTER.splitToList(nullToEmpty(valueString)); return logProperty(lookupKey, value); } HadoopConfigurationProperty(String key);  HadoopConfigurationProperty(String key, T defaultValue, String... deprecatedKeys); HadoopConfigurationProperty<T> withPrefixes(List<String> keyPrefixes); String getKey(); List<String> getDeprecatedKeys(); T getDefault(); T get(Configuration config, BiFunction<String, T, T> getterFn); String getPassword(Configuration config); Collection<String> getStringCollection(Configuration config); @SuppressWarnings("unchecked") Map<String, String> getPropsWithPrefix(Configuration config);  }
@Test public void getStringCollection_throwsExceptionOnNonCollectionProperty() { Configuration config = new Configuration(); HadoopConfigurationProperty<String> stringKey = new HadoopConfigurationProperty<>("actual.key", "default-string"); HadoopConfigurationProperty<Integer> integerKey = new HadoopConfigurationProperty<>("actual.key", 1); HadoopConfigurationProperty<Collection<String>> collectionKey = new HadoopConfigurationProperty<>("collection.key", ImmutableList.of("key1", "key2")); assertThrows(IllegalStateException.class, () -> stringKey.getStringCollection(config)); assertThrows(IllegalStateException.class, () -> integerKey.getStringCollection(config)); assertThat(collectionKey.getStringCollection(config)).containsExactly("key1", "key2").inOrder(); }