From 032935e1a17e531ad37992967bdb2639125fbcc8 Mon Sep 17 00:00:00 2001 From: Tom Bishop Date: Wed, 18 Oct 2023 12:50:50 -0400 Subject: [PATCH] CLDR-16369 Fix some comments and warnings in VoteResolver (#3348) -The comment for VoteResolver.VoteStatus.provisionalOrWorse was incorrect -The comment (see class def for null user) was unhelpful -The reference to ticket/10973 was obsolete -Fix a few warnings from IntelliJ --- .../org/unicode/cldr/util/VoteResolver.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/VoteResolver.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/VoteResolver.java index f61de085193..808e83f5b5b 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/VoteResolver.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/VoteResolver.java @@ -86,7 +86,7 @@ public String getTranscript() { * @param fmt * @param args */ - private final void annotateTranscript(String fmt, Object... args) { + private void annotateTranscript(String fmt, Object... args) { if (DEBUG) { System.out.println("Transcript: " + String.format(fmt, args)); } @@ -108,8 +108,8 @@ private final void annotateTranscript(String fmt, Object... args) { *

Status corresponds to icons as follows: A checkmark means it’s approved and is slated to * be used. A cross means it’s a missing value. Green/orange check: The item has enough votes to * be used in CLDR. Red/orange/black X: The item does not have enough votes to be used in CLDR, - * by most implementations (or is completely missing). Reference: - * http://cldr.unicode.org/translation/getting-started/guide + * by most implementations (or is completely missing). Reference: guide * *

When the item is inherited, i.e., winningValue is INHERITANCE_MARKER (↑↑↑), then * orange/red X are replaced by orange/red up-arrow. That change is made only on the client. @@ -117,6 +117,8 @@ private final void annotateTranscript(String fmt, Object... args) { *

Status.approved: green check Status.contributed: orange check Status.provisional: orange X * (or orange up-arrow if inherited) Status.unconfirmed: red X (or red up-arrow if inherited * Status.missing: black X + * + *

Not to be confused with VoteResolver.VoteStatus */ public enum Status { missing, @@ -296,10 +298,10 @@ public boolean canVoteWithCount(Organization org, int withVotes) { /** * Get the ordered immutable set of different vote counts a user of this level can vote with * - * @param org the given organization + * @param ignoredOrg the given organization * @return the set, or null if the user has no choice of vote count */ - public ImmutableSet getVoteCountMenu(Organization org) { + public ImmutableSet getVoteCountMenu(Organization ignoredOrg) { // Right now, the organization does not affect the menu. // but update the API to future proof. return voteCountMenu; @@ -434,30 +436,31 @@ public boolean canDeleteUsers() { } } - /** See VoteResolver getStatusForOrganization to see how this is computed. */ + /** + * See getStatusForOrganization to see how this is computed. + * + *

Not to be confused with VoteResolver.Status + */ public enum VoteStatus { /** * The value for the path is either contributed or approved, and the user's organization - * didn't vote. (see class def for null user) + * didn't vote. */ ok_novotes, /** * The value for the path is either contributed or approved, and the user's organization - * chose the winning value. (see class def for null user) + * chose the winning value. */ ok, - /** - * The user's organization chose the winning value for the path, but that value is neither - * contributed nor approved. (see class def for null user) - */ + /** The winning value is neither contributed nor approved. */ provisionalOrWorse, /** - * The user's organization's choice is not winning. There may be insufficient votes to - * overcome a previously approved value, or other organizations may be voting against it. - * (see class def for null user) + * The user's organization's choice is not winning, and the winning value is either + * contributed or approved. There may be insufficient votes to overcome a previously + * approved value, or other organizations may be voting against it. */ losing, @@ -589,9 +592,11 @@ private class OrganizationToValueAndVote { /** The result of {@link #getTotals(EnumSet)} */ private final Counter totals = new Counter<>(true); - private Map nameTime = new LinkedHashMap<>(); - // map an organization to what it voted for. + private final Map nameTime = new LinkedHashMap<>(); + + /** map an organization to the value it voted for. */ private final Map orgToAdd = new EnumMap<>(Organization.class); + private T baileyValue; private boolean baileySet; // was the bailey value set @@ -654,7 +659,7 @@ private void addInternal(T value, final VoterInfo info, final int votes, Date ti if (DROP_HARD_INHERITANCE) { value = changeBaileyToInheritance(value); } - /** All votes are added here, even if they will later lose an intra-org dispute. */ + /* All votes are added here, even if they will later lose an intra-org dispute. */ allVotesIncludingIntraOrgDispute.add(value, votes, time.getTime()); nameTime.put(info.getName(), time.getTime()); if (DEBUG) { @@ -1331,8 +1336,7 @@ private HashMap makeVoteCountMap(Set sortedValues) { */ private boolean combineInheritanceWithBaileyForVoting( Set sortedValues, HashMap voteCount) { - if (organizationToValueAndVote == null - || organizationToValueAndVote.baileySet == false + if (organizationToValueAndVote.baileySet == false || organizationToValueAndVote.baileyValue == null) { return false; } @@ -1380,8 +1384,7 @@ private void reallyCombineInheritanceWithBailey( * Sort again */ List list = new ArrayList<>(sortedValues); - Collections.sort( - list, + list.sort( (v1, v2) -> { long c1 = voteCount.get(v1); long c2 = voteCount.get(v2); @@ -1412,9 +1415,6 @@ private void reallyCombineInheritanceWithBailey( * *

http://unicode.org/repos/cldr/tags/latest/common/annotations/ * - *

This function is where the essential algorithm needs to be implemented for - * http://unicode.org/cldr/trac/ticket/10973 - * * @param sortedValues the set of sorted values * @param voteCount the hash giving the vote count for each value in sortedValues *

public for unit testing, see TestAnnotationVotes.java