protected final void set ( M config ) { ArrayList < WeakReference < ConfigListener < M , F > > > iterateOver ; synchronized ( this ) { M old = instance . get ( ) ; if ( old == config || ( old != null && old . equals ( config ) ) ) { return ; } instance . set ( config ) ; lastUpdateTimestamp . set ( clock . millis ( ) ) ; listeners . removeIf ( ref -> ref . get ( ) == null ) ; iterateOver = new ArrayList <> ( listeners ) ; } iterateOver . forEach ( ref -> { ConfigListener < M , F > listener = ref . get ( ) ; if ( listener != null ) { try { listener . onConfigChange ( config ) ; } catch ( Exception ignore ) { // Ignored... TODO: At least log? } } } ) ; }
Set a new config value to the supplier . This is protected as it is usually up to the supplier implementation to enable updating the config at later stages .