Collection<WhiteSpaceFormattingStrategy> () { final WeakReference<Collection<WhiteSpaceFormattingStrategy>> reference = myCachedStrategies.get(); final Collection<WhiteSpaceFormattingStrategy> strategies = SoftReference.dereference(reference); if (strategies != null) { return strategies; } final Collection<Language> languages = Language.getRegisteredLanguages(); Set<WhiteSpaceFormattingStrategy> result = new HashSet<>(); result.add(DEFAULT_STRATEGY); final LanguageWhiteSpaceFormattingStrategy languageStrategy = LanguageWhiteSpaceFormattingStrategy.INSTANCE; for (Language language : languages) { final WhiteSpaceFormattingStrategy strategy = languageStrategy.forLanguage(language); if (strategy != null) { result.add(strategy); } } myCachedStrategies.set(new WeakReference<>(result)); return result; }