public static < K , V > void initOrAddList ( Map < K , List < V > > orginMap , K key , V needAdd ) { List < V > listeners = orginMap . get ( key ) ; if ( listeners == null ) { listeners = new CopyOnWriteArrayList < V > ( ) ; listeners . add ( needAdd ) ; orginMap . put ( key , listeners ) ; } else { listeners . add ( needAdd ) ; } }
Init or add list .