2020public class JLMapEventHandler {
2121 public static final String MAP_TYPE = "map" ;
2222 public static final String MAP_UUID = "main_map" ;
23+
2324 HashMap <Class <? extends JLObject <?>>, HashMap <String , JLObject <?>>> jlObjects ;
2425
2526 HashMap <String , Class <? extends JLObject <?>>[]> classMap ;
@@ -51,13 +52,13 @@ private void initClassMap() {
5152 /**
5253 * @param functionName name of source function from js
5354 * @param jlType name of object class
54- * @param uuid id of object
55+ * @param uuid id of object
5556 * @param param1 additional param
5657 * @param param2 additional param
5758 * @param param3 additional param
5859 */
5960 @ SuppressWarnings ("all" )
60- public void functionCalled (JLObject <?> mapView , String functionName , Object jlType , Object uuid ,
61+ public void functionCalled (JLMap <?> mapView , String functionName , Object jlType , Object uuid ,
6162 Object param1 , Object param2 , Object param3 ) {
6263 log .debug ("function: {} jlType: {} uuid: {} param1: {} param2: {} param3: {}" ,
6364 functionName , jlType , uuid , param1 , param2 , param3 );
@@ -76,23 +77,25 @@ public void functionCalled(JLObject<?> mapView, String functionName, Object jlTy
7677 .map (targetClass -> jlObjects .get (targetClass ).get (String .valueOf (uuid )))
7778 .filter (Objects ::nonNull )
7879 .filter (jlObject -> Objects .nonNull (jlObject .getOnActionListener ()))
79- .forEach (jlObject -> {
80- eventHandlers .stream ()
81- .filter (hadler -> hadler .canHandle (functionName ))
82- .forEach (hadler -> hadler .handle (jlObject , functionName ,
83- jlObject .getOnActionListener (), jlType , uuid , param1 , param2 , param3 ));
84- });
80+ .forEach (jlObject -> invokeEventHandler (functionName , jlType , uuid , param1 , param2 , param3 , mapView , jlObject ));
8581 } else if (MAP_TYPE .equals (jlType ) && MAP_UUID .equals (uuid ) && mapView .getOnActionListener () != null ) {
8682 eventHandlers .stream ()
8783 .filter (hadler -> hadler .canHandle (functionName ))
88- .forEach (hadler -> hadler .handle (mapView , functionName , mapView .getOnActionListener (),
84+ .forEach (hadler -> hadler .handle (mapView , mapView , functionName , mapView .getOnActionListener (),
8985 jlType , uuid , param1 , param2 , param3 ));
9086 }
9187 } catch (Exception e ) {
9288 log .error (e .getMessage (), e );
9389 }
9490 }
9591
92+ private void invokeEventHandler (String functionName , Object jlType , Object uuid , Object param1 , Object param2 , Object param3 , JLMap <?> map , JLObject <?> jlObject ) {
93+ eventHandlers .stream ()
94+ .filter (handler -> handler .canHandle (functionName ))
95+ .forEach (handler -> handler .handle (map , jlObject , functionName ,
96+ jlObject .getOnActionListener (), jlType , uuid , param1 , param2 , param3 ));
97+ }
98+
9699 public void addJLObject (@ NonNull String key , @ NonNull JLObject <?> object ) {
97100 if (jlObjects .containsKey (object .getClass ())) {
98101 jlObjects .get (object .getClass ())
0 commit comments