/* čĊ Ġ* ĠSp onge ĠKnowledge ĠBase čĊ Ġ* ĠTrigger Ġbuild ers čĊ Ġ*/ čĊč Ċ package Ġorg . open ks avi . sponge . kotlin . examples čĊč Ċ import Ġorg . open ks avi . sponge . event . Event č Ċ import Ġorg . open ks avi . sponge . kotlin . KK nowledge Base č Ċ import Ġorg . open ks avi . sponge . kotlin . K Trigger č Ċ import Ġjava . util . concurrent . atomic . Atomic Boolean č Ċ import Ġjava . util . concurrent . atomic . Atomic Integer č Ċ import Ġorg . open ks avi . sponge . kotlin . K Trigger Builder čĊč Ċ class ĠT riggers Builder Ġ: ĠK Knowledge Base () Ġ{ čĊčĊĠĠĠ Ġoverride Ġfun Ġon Init () Ġ{ čĊĠĠĠĠĠĠĠ Ġ// ĠVariables Ġfor Ġassertions Ġonly čĊĠĠĠĠĠĠĠ Ġsp onge . set Variable (" received Event A ", ĠAtomic Boolean ( false )) čĊĠĠĠĠĠĠĠ Ġsp onge . set Variable (" received Event B Count ", ĠAtomicInteger ( 0 )) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġoverride Ġfun ĠonLoad () Ġ{ čĊĠĠĠĠĠĠĠ Ġsp onge . enable ( K Trigger Builder (" Trigger A "). with Event (" a "). with On Run ({ Ġtrigger , Ġevent Ġ-> čĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrigger . logger . debug (" Received Ġevent Ġ{}", Ġevent ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġsp onge . get Variable < Atomic Boolean >(" received Event A "). set ( true ) čĊĠĠĠĠĠĠĠ Ġ})) čĊčĊĠĠĠĠĠĠĠ Ġsp onge . enable ( K Trigger Builder (" Trigger B "). with Event (" b "). with On Run ({ Ġtrigger , Ġevent Ġ-> čĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrigger . logger . debug (" Received Ġevent Ġ{}", Ġevent ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreceived Event B Count Ġ= Ġsp onge . get Variable < Atomic Integer >(" received Event B Count ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( received Event B Count . get () Ġ== Ġ 0 ) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrigger . logger . debug (" Statistics : Ġ{}", Ġsp onge . statistics Summary ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} čĊĠĠĠĠĠĠĠĠĠĠĠ Ġreceived Event B Count . increment AndGet () čĊĠĠĠĠĠĠĠ Ġ})) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġoverride Ġfun Ġon Startup () Ġ{ čĊĠĠĠĠĠĠĠ Ġlogger . debug (" Startup Ġ{}, Ġtriggers : Ġ{}", Ġsp onge . info , Ġsp onge . engine . triggers ) čĊĠĠĠĠĠĠĠ Ġlogger . debug (" Knowledge Ġbase Ġname : Ġ{}", Ġsp onge . kb . name ) čĊĠĠĠĠĠĠĠ Ġsp onge . event (" a "). send () čĊĠĠĠĠĠĠĠ Ġsp onge . event (" b "). send After ( 2 0 0 , Ġ 2 0 0 ) čĊĠĠĠ Ġ} č Ċ } čĊ