1616import io .nats .client .support .JsonValue ;
1717
1818import java .time .ZonedDateTime ;
19+ import java .util .HashMap ;
1920import java .util .List ;
21+ import java .util .Map ;
2022
2123import static io .nats .client .support .ApiConstants .*;
2224import static io .nats .client .support .JsonValueUtils .*;
@@ -34,6 +36,7 @@ public class StreamState {
3436 private final List <Subject > subjects ;
3537 private final List <Long > deletedStreamSequences ;
3638 private final LostStreamData lostStreamData ;
39+ private final Map <String , Long > subjectMap ;
3740
3841 StreamState (JsonValue vStreamState ) {
3942 msgs = readLong (vStreamState , MESSAGES , 0 );
@@ -48,6 +51,11 @@ public class StreamState {
4851 subjects = Subject .listOf (readValue (vStreamState , SUBJECTS ));
4952 deletedStreamSequences = readLongList (vStreamState , DELETED );
5053 lostStreamData = LostStreamData .optionalInstance (readValue (vStreamState , LOST ));
54+
55+ subjectMap = new HashMap <>();
56+ for (Subject s : subjects ) {
57+ subjectMap .put (s .getName (), s .getCount ());
58+ }
5159 }
5260
5361 /**
@@ -122,14 +130,22 @@ public long getSubjectCount() {
122130 }
123131
124132 /**
125- * Get a list of the Subject objects. May be null if the Stream Info request did not ask for subjects
126- * or if there are no subjects.
133+ * Get a list of the Subject objects. May be empty, for instance
134+ * if the Stream Info request did not ask for subjects or if there are no subjects.
127135 * @return the list of subjects
128136 */
129137 public List <Subject > getSubjects () {
130138 return subjects ;
131139 }
132140
141+ /**
142+ * Get a map of subjects instead of a list of Subject objects.
143+ * @return the map
144+ */
145+ public Map <String , Long > getSubjectMap () {
146+ return subjectMap ;
147+ }
148+
133149 /**
134150 * Gets the count of deleted messages
135151 *
0 commit comments