Skip to content

Commit 79db9be

Browse files
committed
ICU-23270 Apply source formatter to all Java files in /tools
1 parent 74dd9a7 commit 79db9be

File tree

88 files changed

+5810
-4057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+5810
-4057
lines changed

tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/AlternateLocaleData.java

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,36 @@
77
import static com.google.common.collect.ImmutableSet.toImmutableSet;
88
import static org.unicode.cldr.api.CldrDataType.LDML;
99

10+
import com.google.common.collect.ImmutableMap;
11+
import com.google.common.collect.ImmutableSet;
12+
import com.google.common.collect.ImmutableTable;
13+
import com.google.common.collect.Table;
1014
import java.util.HashMap;
1115
import java.util.Map;
1216
import java.util.Set;
13-
1417
import org.unicode.cldr.api.CldrData;
1518
import org.unicode.cldr.api.CldrDataSupplier;
1619
import org.unicode.cldr.api.CldrDataType;
1720
import org.unicode.cldr.api.CldrDraftStatus;
1821
import org.unicode.cldr.api.CldrPath;
1922
import org.unicode.cldr.api.CldrValue;
2023

21-
import com.google.common.collect.ImmutableMap;
22-
import com.google.common.collect.ImmutableSet;
23-
import com.google.common.collect.ImmutableTable;
24-
import com.google.common.collect.Table;
25-
2624
/**
27-
* A factory for data suppliers which can filter CLDR values by substituting values from one path
28-
* to another. The replaced value must retain the original "target" path but will have the value
29-
* and value attributes of the "source". A value will only be replaced if both the source and
30-
* target paths have associated values. The replacement retains its original position in the value
25+
* A factory for data suppliers which can filter CLDR values by substituting values from one path to
26+
* another. The replaced value must retain the original "target" path but will have the value and
27+
* value attributes of the "source". A value will only be replaced if both the source and target
28+
* paths have associated values. The replacement retains its original position in the value
3129
* ordering.
3230
*
33-
* <p>This class DOES NOT transform supplemental or BCP-47 data, because the use of "alt" values
34-
* is completely different for that data (it would require merging specific attributes together).
31+
* <p>This class DOES NOT transform supplemental or BCP-47 data, because the use of "alt" values is
32+
* completely different for that data (it would require merging specific attributes together).
3533
*
36-
* <p>Note that this is not a general purpose transformation of CLDR data, since it is generally
37-
* not possible to "move" values between arbitrary paths. Target and source paths must be in the
38-
* same "namespace" (i.e. share the same element names) but attributes can differ.
34+
* <p>Note that this is not a general purpose transformation of CLDR data, since it is generally not
35+
* possible to "move" values between arbitrary paths. Target and source paths must be in the same
36+
* "namespace" (i.e. share the same element names) but attributes can differ.
3937
*
40-
* <p>Note also that the mapping is not recursive, so mapping {@code A -> B} and {@code B -> C}
41-
* will NOT cause {@code A} to be mapped to {@code C}.
38+
* <p>Note also that the mapping is not recursive, so mapping {@code A -> B} and {@code B -> C} will
39+
* NOT cause {@code A} to be mapped to {@code C}.
4240
*
4341
* <p>Typically this class is expected to be used for selecting alternate values of locale data
4442
* based on the {@code "alt"} path attribute (e.g. selecting the short form of a region name).
@@ -52,9 +50,9 @@ public final class AlternateLocaleData {
5250
* namespace (i.e. have the same path element names).
5351
*/
5452
public static CldrDataSupplier transform(
55-
CldrDataSupplier src,
56-
Map<CldrPath, CldrPath> globalAltPaths,
57-
Table<String, CldrPath, CldrPath> localeAltPaths) {
53+
CldrDataSupplier src,
54+
Map<CldrPath, CldrPath> globalAltPaths,
55+
Table<String, CldrPath, CldrPath> localeAltPaths) {
5856
return new CldrDataFilter(src, globalAltPaths, localeAltPaths);
5957
}
6058

@@ -66,26 +64,37 @@ private static final class CldrDataFilter extends CldrDataSupplier {
6664
private final ImmutableTable<String, CldrPath, CldrPath> localeAltPaths;
6765

6866
CldrDataFilter(
69-
CldrDataSupplier src,
70-
Map<CldrPath, CldrPath> globalAltPaths,
71-
Table<String, CldrPath, CldrPath> localeAltPaths) {
67+
CldrDataSupplier src,
68+
Map<CldrPath, CldrPath> globalAltPaths,
69+
Table<String, CldrPath, CldrPath> localeAltPaths) {
7270
this.src = checkNotNull(src);
7371
this.globalAltPaths = ImmutableMap.copyOf(globalAltPaths);
7472
this.localeAltPaths = ImmutableTable.copyOf(localeAltPaths);
75-
this.globalAltPaths
76-
.forEach((t, s) -> checkArgument(hasSameNamespace(checkLdml(t), checkLdml(s)),
77-
"alternate paths must have the same namespace: target=%s, source=%s", t, s));
78-
this.localeAltPaths.cellSet()
79-
.forEach(c -> checkArgument(
80-
hasSameNamespace(checkLdml(c.getColumnKey()), checkLdml(c.getValue())),
81-
"alternate paths must have the same namespace: locale=%s, target=%s, source=%s",
82-
c.getRowKey(), c.getColumnKey(), c.getValue()));
73+
this.globalAltPaths.forEach(
74+
(t, s) ->
75+
checkArgument(
76+
hasSameNamespace(checkLdml(t), checkLdml(s)),
77+
"alternate paths must have the same namespace: target=%s, source=%s",
78+
t,
79+
s));
80+
this.localeAltPaths
81+
.cellSet()
82+
.forEach(
83+
c ->
84+
checkArgument(
85+
hasSameNamespace(
86+
checkLdml(c.getColumnKey()),
87+
checkLdml(c.getValue())),
88+
"alternate paths must have the same namespace: locale=%s, target=%s, source=%s",
89+
c.getRowKey(),
90+
c.getColumnKey(),
91+
c.getValue()));
8392
}
8493

8594
@Override
8695
public CldrDataSupplier withDraftStatusAtLeast(CldrDraftStatus draftStatus) {
8796
return new CldrDataFilter(
88-
src.withDraftStatusAtLeast(draftStatus), globalAltPaths, localeAltPaths);
97+
src.withDraftStatusAtLeast(draftStatus), globalAltPaths, localeAltPaths);
8998
}
9099

91100
@Override
@@ -114,7 +123,7 @@ private final class AltData extends FilteredData {
114123

115124
AltData(CldrData srcData, String localeId) {
116125
super(srcData);
117-
ImmutableMap<CldrPath, CldrPath> altPaths = globalAltPaths;
126+
ImmutableMap<CldrPath, CldrPath> altPaths = globalAltPaths;
118127
if (!localeAltPaths.row(localeId).isEmpty()) {
119128
Map<CldrPath, CldrPath> combinedPaths = new HashMap<>();
120129
// Locale specific path mappings overwrite global ones.
@@ -123,14 +132,17 @@ private final class AltData extends FilteredData {
123132
altPaths = ImmutableMap.copyOf(combinedPaths);
124133
}
125134
this.altPaths = altPaths;
126-
this.toRemove = altPaths.entrySet().stream()
127-
// Only remove source paths that are not also target paths...
128-
.filter(e -> !this.altPaths.containsKey(e.getValue()))
129-
// ... and if the target path it will be transformed to actually exists.
130-
.filter(e -> getSourceData().get(e.getKey()) != null)
131-
// The value in the mapping is the source path (it's target->source for lookup).
132-
.map(Map.Entry::getValue)
133-
.collect(toImmutableSet());
135+
this.toRemove =
136+
altPaths.entrySet().stream()
137+
// Only remove source paths that are not also target paths...
138+
.filter(e -> !this.altPaths.containsKey(e.getValue()))
139+
// ... and if the target path it will be transformed to actually
140+
// exists.
141+
.filter(e -> getSourceData().get(e.getKey()) != null)
142+
// The value in the mapping is the source path (it's target->source
143+
// for lookup).
144+
.map(Map.Entry::getValue)
145+
.collect(toImmutableSet());
134146
}
135147

136148
@Override

0 commit comments

Comments
 (0)