This little bit is mixing 2 levels of abstraction. In the condition, the check is implicitly checking if it is dealing with a 'java name', but it is doing it without the abstraction provided by .fromJavaName. To keep it at the same abstraction level it should be something like:

```java
if (LocaleId.isJavaName(lang))
{
   // log
   return LocaleId.fromJavaName(lang).getId();
   ...
```