This repository was archived by the owner on Mar 3, 2026. It is now read-only.
Commit 6afd692
committed
Refactor the Request locale API
Following the addition of:
- `List<Locale> locales(BiFunction<List<Locale.LanguageRange>, List<Locale>, List<Locale>> filter`
- `Locale locale(BiFunction<List<Locale.LanguageRange>, List<Locale>, Locale> filter)`
`Locale locale(Iterable<Locale> locales)` and `Locale locale(Locale... locales)`
were made redundant by the new two functions. This use case can be implemented
in the following way:
List<Locale> supportedLocales = ...
Locale locale = req.locale((ranges, locales) ->
Locale.lookup(ranges, supportedLocales));
`List<Locale> locales()` is just an shorthand for `locales(Locale::filter)`.
`Locale locale()` simply returns the first element of `locales` or the default
locale as per `app.lang` if there are no matches. This function is expected to
be the most used one.
Issue jooby-project#2731 parent 2eca216 commit 6afd692
File tree
6 files changed
+56
-113
lines changed- coverage-report/src/test/java/org/jooby/issues
- jooby/src
- main/java/org/jooby
- internal
- test/java/org/jooby
6 files changed
+56
-113
lines changedLines changed: 41 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
23 | 55 | | |
24 | 56 | | |
25 | 57 | | |
26 | 58 | | |
27 | 59 | | |
28 | 60 | | |
29 | | - | |
| 61 | + | |
30 | 62 | | |
31 | 63 | | |
32 | 64 | | |
Lines changed: 1 addition & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 19 | | |
25 | 20 | | |
26 | | - | |
27 | | - | |
| 21 | + | |
28 | 22 | | |
29 | 23 | | |
30 | 24 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 25 | | |
38 | 26 | | |
39 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | 197 | | |
203 | 198 | | |
204 | 199 | | |
| |||
210 | 205 | | |
211 | 206 | | |
212 | 207 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | 208 | | |
219 | 209 | | |
220 | 210 | | |
| |||
645 | 635 | | |
646 | 636 | | |
647 | 637 | | |
648 | | - | |
649 | | - | |
| 638 | + | |
650 | 639 | | |
651 | | - | |
| 640 | + | |
652 | 641 | | |
653 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
654 | 645 | | |
655 | 646 | | |
656 | 647 | | |
| |||
671 | 662 | | |
672 | 663 | | |
673 | 664 | | |
674 | | - | |
| 665 | + | |
675 | 666 | | |
676 | 667 | | |
677 | 668 | | |
| |||
684 | 675 | | |
685 | 676 | | |
686 | 677 | | |
687 | | - | |
| 678 | + | |
688 | 679 | | |
689 | 680 | | |
690 | 681 | | |
691 | 682 | | |
692 | | - | |
693 | | - | |
| 683 | + | |
| 684 | + | |
694 | 685 | | |
695 | | - | |
| 686 | + | |
696 | 687 | | |
697 | 688 | | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
723 | 693 | | |
724 | 694 | | |
725 | 695 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | 277 | | |
283 | 278 | | |
284 | 279 | | |
| |||
292 | 287 | | |
293 | 288 | | |
294 | 289 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | 290 | | |
304 | 291 | | |
305 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | 413 | | |
438 | 414 | | |
439 | 415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 100 | | |
106 | 101 | | |
107 | 102 | | |
| |||
113 | 108 | | |
114 | 109 | | |
115 | 110 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | 111 | | |
122 | 112 | | |
123 | 113 | | |
| |||
0 commit comments