protected void appendEventGuardEvaluators ( JvmGenericType container ) { final GenerationContext context = getContext ( container ) ; if ( context != null ) { final Collection < Pair < SarlBehaviorUnit , Collection < Procedure1 < ? super ITreeAppendable > > > > allEvaluators = context . getGuardEvaluationCodes ( ) ; if ( allEvaluators == null || allEvaluators . isEmpty ( ) ) { return ; } final JvmTypeReference voidType = this . _typeReferenceBuilder . typeRef ( Void . TYPE ) ; final JvmTypeReference runnableType = this . _typeReferenceBuilder . typeRef ( Runnable . class ) ; final JvmTypeReference collectionType = this . _typeReferenceBuilder . typeRef ( Collection . class , runnableType ) ; for ( final Pair < SarlBehaviorUnit , Collection < Procedure1 < ? super ITreeAppendable > > > evaluators : allEvaluators ) { final SarlBehaviorUnit source = evaluators . getKey ( ) ; // Determine the name of the operation for the behavior output final String behName = Utils . createNameForHiddenGuardGeneralEvaluatorMethod ( source . getName ( ) . getSimpleName ( ) ) ; // Create the main function final JvmOperation operation = this . typesFactory . createJvmOperation ( ) ; // Annotation for the event bus appendGeneratedAnnotation ( operation , context ) ; addAnnotationSafe ( operation , PerceptGuardEvaluator . class ) ; // Guard evaluator unit parameters // - Event occurrence JvmFormalParameter jvmParam = this . typesFactory . createJvmFormalParameter ( ) ; jvmParam . setName ( this . grammarKeywordAccess . getOccurrenceKeyword ( ) ) ; jvmParam . setParameterType ( this . typeBuilder . cloneWithProxies ( source . getName ( ) ) ) ; this . associator . associate ( source , jvmParam ) ; operation . getParameters ( ) . add ( jvmParam ) ; // - List of runnables jvmParam = this . typesFactory . createJvmFormalParameter ( ) ; jvmParam . setName ( RUNNABLE_COLLECTION ) ; jvmParam . setParameterType ( this . typeBuilder . cloneWithProxies ( collectionType ) ) ; operation . getParameters ( ) . add ( jvmParam ) ; operation . setAbstract ( false ) ; operation . setNative ( false ) ; operation . setSynchronized ( false ) ; operation . setStrictFloatingPoint ( false ) ; operation . setFinal ( false ) ; operation . setVisibility ( JvmVisibility . PRIVATE ) ; operation . setStatic ( false ) ; operation . setSimpleName ( behName ) ; operation . setReturnType ( this . typeBuilder . cloneWithProxies ( voidType ) ) ; container . getMembers ( ) . add ( operation ) ; setBody ( operation , it -> { it . append ( "assert " ) ; //$NON-NLS-1$ it . append ( this . grammarKeywordAccess . getOccurrenceKeyword ( ) ) ; it . append ( " != null;" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "assert " ) ; //$NON-NLS-1$ it . append ( RUNNABLE_COLLECTION ) ; it . append ( " != null;" ) ; //$NON-NLS-1$ for ( final Procedure1 < ? super ITreeAppendable > code : evaluators . getValue ( ) ) { it . newLine ( ) ; code . apply ( it ) ; } } ) ; this . associator . associatePrimary ( source , operation ) ; this . typeBuilder . copyDocumentationTo ( source , operation ) ; } } }
Append the guard evaluators .