arjunashok commented on code in PR #166:
URL: https://github.com/apache/cassandra-sidecar/pull/166#discussion_r1927587840


##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/data/StreamState.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.sidecar.adapters.base.data;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.Collectors;
+import javax.management.openmbean.CompositeData;
+
+/**
+ * Representation of the stream state data
+ */
+public class StreamState
+{
+    Collection<SessionInfo> sessions;
+
+    public StreamState(CompositeData data)
+    {
+        this.sessions = parseSessions((CompositeData[]) data.get("sessions"));
+    }
+
+    private Collection<SessionInfo> parseSessions(CompositeData[] sessions)
+    {
+        return 
Arrays.stream(sessions).map(SessionInfo::new).collect(Collectors.toList());

Review Comment:
   I would argue that this is more readable given it's a simple transformation 
to a class type (each transformation could be on a newline if needed, but 
that's a styling aspect). Also I see several references across sidecar codebase 
of similar usage. 
   
   If we want to make a concerted effort move away from stream usage in 
sidecar, we should have a broader discussion with consensus if it makes sense 
for sidecar, which I feel is outside the scope of this PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to