This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push: new 70436ca7 Make package-private class private and final: IntersectionSimilarity.BagCount. 70436ca7 is described below commit 70436ca75ed10dd72269d4218a0cb844276d0ba9 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue Apr 23 16:11:51 2024 -0400 Make package-private class private and final: IntersectionSimilarity.BagCount. Make package-private class private and final: IntersectionSimilarity.TinyCount --- src/changes/changes.xml | 6 ++++-- .../text/similarity/IntersectionSimilarity.java | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b55bb3f8..d4cec1c4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -49,14 +49,16 @@ The <action> type attribute can be add,update,fix,remove. <!-- FIX --> <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix build on Java 22.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix build on Java 23-ea.</action> - <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private constructor private: org.apache.commons.text.StrLookup.MapStrLookup.MapStrLookup(Map).</action> - <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private constructor private: org.apache.commons.text.StrLookup.SystemPropertiesStrLookup.SystemPropertiesStrLookup().</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private constructor private: StrLookup.MapStrLookup.MapStrLookup(Map).</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private constructor private: StrLookup.SystemPropertiesStrLookup.SystemPropertiesStrLookup().</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private and final: MapStrLookup.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private: StrMatcher.CharMatcher.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private: StrMatcher.CharSetMatcher.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private: StrMatcher.NoMatcher.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private: StrMatcher.StringMatcher.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private: StrMatcher.TrimMatcher.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private and final: IntersectionSimilarity.BagCount.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Make package-private class private and final: IntersectionSimilarity.TinyCount.</action> <!-- UPDATE --> <action type="udpate" dev="ggregory" due-to="Gary Gregory">Bump tests on Java >= 22 org.graalvm.*:* from 24.0.0 to 24.0.1.</action> </release> diff --git a/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java b/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java index d7a4d3ed..40e9f23f 100644 --- a/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java +++ b/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java @@ -46,7 +46,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe private static final BagCount ZERO = new BagCount(); /** The count. */ - int count; + private int count; private BagCount() { this.count = 0; @@ -60,10 +60,13 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe /** * A minimal implementation of a Bag that can store elements and a count. * - * <p>For the intended purpose the Bag does not have to be a {@link Collection}. It does not + * <p> + * For the intended purpose the Bag does not have to be a {@link Collection}. It does not * even have to know its own size. + * </p> */ - private class TinyBag { + private final class TinyBag { + /** The backing map. */ private final Map<T, BagCount> map; @@ -72,7 +75,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe * * @param initialCapacity the initial capacity */ - TinyBag(final int initialCapacity) { + private TinyBag(final int initialCapacity) { map = new HashMap<>(initialCapacity); } @@ -81,7 +84,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe * * @param object the object to add */ - void add(final T object) { + private void add(final T object) { map.computeIfAbsent(object, k -> new BagCount()).count++; } @@ -90,7 +93,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe * * @return The Set view */ - Set<Entry<T, BagCount>> entrySet() { + private Set<Entry<T, BagCount>> entrySet() { return map.entrySet(); } @@ -101,7 +104,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe * @param object the object to search for * @return The number of occurrences of the object, zero if not found */ - int getCount(final Object object) { + private int getCount(final Object object) { return map.getOrDefault(object, BagCount.ZERO).count; } @@ -110,7 +113,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe * * @return The unique element size */ - int uniqueElementSize() { + private int uniqueElementSize() { return map.size(); } }