@@ -25,22 +25,30 @@ public class ISO_639 {
25
25
static ThreadLocal <Function <String , ISO_639_Code >> notFoundFallback = ThreadLocal .withInitial (() -> c -> NOTFOUND );
26
26
27
27
/**
28
- * If a code is not found in {@link #iso639(String)}, to throw {@link LanguageNotFoundException}, but return {@code null}
28
+ * If a code is not found in {@link #iso639(String)}, do not throw {@link LanguageNotFoundException}, but return {@link LanguageCode#NOTFOUND}
29
+ * @see #implicitUserDefine()
29
30
*/
30
31
public static RemoveIgnoreNotFound setIgnoreNotFound () {
31
- return setIgnoreNotFound (null );
32
+ ignoreNotFound .set (Boolean .TRUE );
33
+ notFoundFallback .remove ();
34
+ return RemoveIgnoreNotFound .INSTANCE ;
32
35
}
33
36
34
37
/**
35
- * If a code is not found in {@link #iso639(String)}, to throw {@link LanguageNotFoundException}, but produce use given function
38
+ * If a code is not found in {@link #iso639(String)}, do not throw {@link LanguageNotFoundException}, but produce use given function
36
39
* @param fallback What to produce in those cases
40
+ * @since 3.8
37
41
*/
38
42
public static RemoveIgnoreNotFound setIgnoreNotFound (Function <String , ISO_639_Code > fallback ) {
39
43
ignoreNotFound .set (Boolean .TRUE );
40
44
notFoundFallback .set (fallback );
41
45
return RemoveIgnoreNotFound .INSTANCE ;
42
46
}
43
47
48
+ /**
49
+ * If a code is not found in {@link #iso639(String)}, do not throw {@link LanguageNotFoundException}, but create {@link UserDefinedLanguage}
50
+ * @since 3.8
51
+ */
44
52
public static RemoveIgnoreNotFound implicitUserDefine () {
45
53
ignoreNotFound .set (true );
46
54
notFoundFallback .set (c -> new UserDefinedLanguage (c , null , c , "not found" ));
@@ -239,6 +247,7 @@ public static Optional<ISO_639_Code> get(String code) {
239
247
* @throws LanguageNotFoundException if not found, unless {@link ISO_639#setIgnoreNotFound()} was set, in which case {@link LanguageCode#NOTFOUND}
240
248
* @see #setIgnoreNotFound()
241
249
* @see #setIgnoreNotFound(Function)
250
+ * @see #implicitUserDefine()
242
251
*/
243
252
public static ISO_639_Code iso639 (String code ) {
244
253
if (ignoreNotFound .get ()) {
0 commit comments