11using Lucene . Net . Index ;
2+ using Lucene . Net . Support ;
23using System . Collections . Generic ;
34using JCG = J2N . Collections . Generic ;
45
@@ -32,7 +33,7 @@ namespace Lucene.Net.Search.Grouping
3233 /// The <typeparamref name="TGroupValue"/> type parameter is LUCENENET specific to allow for
3334 /// strongly-typed group values.
3435 /// </remarks>
35- public abstract class AbstractDistinctValuesCollector < GC , TGroupValue > : ICollector
36+ public abstract class AbstractDistinctValuesCollector < GC , TGroupValue > : IAbstractDistinctValuesCollector
3637 where GC : AbstractDistinctValuesCollector . GroupCount < TGroupValue >
3738 {
3839 /// <summary>
@@ -74,6 +75,16 @@ public virtual void SetScorer(Scorer scorer)
7475 /// </summary>
7576 /// <param name="context">next atomic reader context </param>
7677 public abstract void SetNextReader ( AtomicReaderContext context ) ;
78+
79+ #region Explicit interface implementations
80+
81+ /// <summary>
82+ /// LUCENENET specific implementation to provide a non-generic abstraction
83+ /// </summary>
84+ IList < AbstractDistinctValuesCollector . IGroupCount > IAbstractDistinctValuesCollector . Groups
85+ => new CastingListAdapter < GC , AbstractDistinctValuesCollector . IGroupCount > ( Groups ) ;
86+
87+ #endregion
7788 }
7889
7990 /// <summary>
@@ -93,7 +104,7 @@ public static class AbstractDistinctValuesCollector // LUCENENET specific: CA105
93104 /// LUCENENET - removed this class from being a nested class of
94105 /// <see cref="AbstractDistinctValuesCollector{GC, TGroupValue}"/>
95106 /// </remarks>
96- public abstract class GroupCount < TGroupValue >
107+ public abstract class GroupCount < TGroupValue > : IGroupCount
97108 {
98109 public TGroupValue GroupValue { get ; protected set ; }
99110 public ISet < TGroupValue > UniqueValues { get ; protected set ; }
@@ -103,6 +114,37 @@ protected GroupCount(TGroupValue groupValue) // LUCENENET: CA1012: Abstract type
103114 this . GroupValue = groupValue ;
104115 this . UniqueValues = new JCG . HashSet < TGroupValue > ( ) ;
105116 }
117+
118+ #region Explicit interface implementations
119+
120+ object IGroupCount . GroupValue => GroupValue ;
121+
122+ ISet < object > IGroupCount . UniqueValues => new CastingSetAdapter < TGroupValue , object > ( UniqueValues ) ;
123+
124+ #endregion
106125 }
126+
127+ /// <summary>
128+ /// LUCENENET specific interface to provide a non-generic abstraction
129+ /// for <see cref="GroupCount{TGroupValue}"/>.
130+ /// </summary>
131+ public interface IGroupCount
132+ {
133+ object GroupValue { get ; }
134+
135+ ISet < object > UniqueValues { get ; }
136+ }
137+ }
138+
139+ /// <summary>
140+ /// LUCENENET specific interface to provide a non-generic abstraction
141+ /// for <see cref="AbstractDistinctValuesCollector{GC, TGroupValue}"/>.
142+ /// </summary>
143+ public interface IAbstractDistinctValuesCollector : ICollector
144+ {
145+ /// <summary>
146+ /// Returns all unique values for each top N group.
147+ /// </summary>
148+ IList < AbstractDistinctValuesCollector . IGroupCount > Groups { get ; }
107149 }
108150}
0 commit comments