@ SuppressWarnings ( "unchecked" ) public static void updateSocialTone ( Map < String , Object > user , List < ToneScore > socialTone , boolean maintainHistory ) { List < String > currentSocial = new ArrayList < String > ( ) ; Map < String , Object > currentSocialObject = new HashMap < String , Object > ( ) ; for ( ToneScore tone : socialTone ) { if ( tone . getScore ( ) >= SOCIAL_HIGH_SCORE_THRESHOLD ) { currentSocial . add ( tone . getToneName ( ) . toLowerCase ( ) + "_high" ) ; currentSocialObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentSocialObject . put ( "score" , tone . getScore ( ) ) ; currentSocialObject . put ( "interpretation" , "likely high" ) ; } else if ( tone . getScore ( ) <= SOCIAL_LOW_SCORE_THRESHOLD ) { currentSocial . add ( tone . getToneName ( ) . toLowerCase ( ) + "_low" ) ; currentSocialObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentSocialObject . put ( "score" , tone . getScore ( ) ) ; currentSocialObject . put ( "interpretation" , "likely low" ) ; } else { currentSocialObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentSocialObject . put ( "score" , tone . getScore ( ) ) ; currentSocialObject . put ( "interpretation" , "likely medium" ) ; } } // update user language tone Map < String , Object > social = ( Map < String , Object > ) ( ( Map < String , Object > ) user . get ( "tone" ) ) . get ( "social" ) ; social . put ( "current" , currentSocial ) ; // if history needs to be maintained if ( maintainHistory ) { List < Map < String , Object > > history = new ArrayList < Map < String , Object > > ( ) ; if ( social . get ( "history" ) != null ) { history = ( List < Map < String , Object > > ) social . get ( "history" ) ; } history . add ( currentSocialObject ) ; social . put ( "history" , history ) ; } }
updateSocialTone updates the user with the social tones interpreted based on the specified thresholds .