Factory method as constructor replacement. @param lang language setting @return chached instance
(Locale lang)
| 230 | * @return chached instance |
| 231 | */ |
| 232 | static UnitPatterns of(Locale lang) { |
| 233 | |
| 234 | if (lang == null) { |
| 235 | throw new NullPointerException("Missing language."); |
| 236 | } |
| 237 | |
| 238 | UnitPatterns p = CACHE.get(lang); |
| 239 | |
| 240 | if (p == null) { |
| 241 | p = new UnitPatterns(lang); |
| 242 | UnitPatterns old = CACHE.putIfAbsent(lang, p); |
| 243 | if (old != null) { |
| 244 | p = old; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | return p; |
| 249 | |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * <p>Yields a unit pattern which optionally contains a placeholder |
no test coverage detected