public FieldSpec buildConditionField ( int index , Struct < PluralType > branch ) { String fieldDoc = PluralRulePrinter . print ( branch ) ; String name = String . format ( "COND_%d" , index ) ; FieldSpec . Builder field = FieldSpec . builder ( PLURAL_CONDITION , name , PRIVATE , STATIC , FINAL ) . addJavadoc ( fieldDoc + "\n" ) ; List < Node < PluralType > > expressions = branch . nodes ( ) ; CodeBlock . Builder code = CodeBlock . builder ( ) ; code . beginControlFlow ( "(o) ->" ) ; int size = expressions . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { renderExpr ( i == 0 , code , expressions . get ( i ) ) ; } code . addStatement ( "return true" ) ; code . endControlFlow ( ) ; field . initializer ( code . build ( ) ) ; return field . build ( ) ; }
Constructs a lambda Condition field that represents a chain of AND conditions that together is a single branch in an OR condition .