Java extends AbstractLanguage { @Override public String[] getFileSuffixes() { String[] suffixes = Arrays.stream(settings.getStringArray(Java.FILE_SUFFIXES_KEY)).filter(s -> s != null && !s.trim().isEmpty()).toArray(String[]::new); if (suffixes.length == 0) { suffixes = Iterables.toArray(Splitter.on(',').split(DEFAULT_FILE_SUFFIXES), String.class); } return suffixes; } Java(Configuration settings); @Override String[] getFileSuffixes(); static final String KEY; static final String NAME; static final String FILE_SUFFIXES_KEY; static final String DEFAULT_FILE_SUFFIXES; static final String SOURCE_VERSION; static final String DEBUG_RULE_KEY; }
@Test void should_return_java_file_suffixes() { MapSettings settings = new MapSettings(); Java language = new Java(settings.asConfig()); assertThat(language.getFileSuffixes()).containsOnly(".java", ".jav"); settings.setProperty(Java.FILE_SUFFIXES_KEY, ""); assertThat(language.getFileSuffixes()).containsOnly(".java", ".jav"); settings.setProperty(Java.FILE_SUFFIXES_KEY, ".bar, .foo"); assertThat(language.getFileSuffixes()).containsOnly(".bar", ".foo"); }