This is the method I followed,
data.stream().collect(Collectors
.groupingBy(SubscriberActivityAggData::getSubscriberAddress
, Collectors.mapping(SubscriberActivityAggData::getAppId, Collectors.toSet())));
but the Set contains only one unique value.
but when I use Collectors.toList all values are obtained.
data.stream().collect(Collectors
.groupingBy(SubscriberActivityAggData::getSubscriberAddress
, Collectors.mapping(SubscriberActivityAggData::getAppId, Collectors.toList())));
is there an issue with the implementation, I want to get the unique set of appIds.
I want to obtain all the unique app Ids, there are duplicate records with the same app ids in the data object. It's a
List<SubscriberActivityAggData>
of objects.
this is the object structure
@Column(name = "subscriber_address")
String subscriberAddress;
@Column(name = "event_time")
Date eventTime;
@Column(name = "app_id")
String appId;
Input "data" variable
SubscriberActivityAggData{subscriberAddress='77123456', eventTime=Thu Nov 14 00:39:04 IST 2019, appId='APP_999674357'}
SubscriberActivityAggData{subscriberAddress='77123456', eventTime=Sun Nov 10 07:45:51 IST 2019, appId='APP_999001564'}
SubscriberActivityAggData{subscriberAddress='77876', eventTime=Wed Nov 13 00:32:51 IST 2019, appId='APP_999542061'}
SubscriberActivityAggData{subscriberAddress='77876', eventTime=Sun Nov 10 13:55:22 IST 2019, appId='APP_999772967'}
Current Output
77876 -> APP_999772967
77123456 -> APP_999001564
Expected Output
77876 -> APP_999772967,APP_999542061
77123456 -> APP_999001564,APP_999674357