public void checkAllGroupsSatisfied ( final String currentPath ) { StringBuilder errors = new StringBuilder ( ) ; for ( OneOfGroup group : this . mapping . values ( ) ) { if ( group . satisfiedBy . isEmpty ( ) ) { errors . append ( "\n" ) ; errors . append ( "\t* The OneOf choice: " ) . append ( group . name ) . append ( " was not satisfied. One (and only one) of the " ) ; errors . append ( "following fields is required in the request data: " ) . append ( toNames ( group . choices ) ) ; } Collection < OneOfSatisfier > oneOfSatisfiers = Collections2 . filter ( group . satisfiedBy , input -> ! input . isCanSatisfy ) ; if ( oneOfSatisfiers . size ( ) > 1 ) { errors . append ( "\n" ) ; errors . append ( "\t* The OneOf choice: " ) . append ( group . name ) . append ( " was satisfied by too many fields. Only one choice " ) ; errors . append ( "may be in the request data. The fields found were: " ) . append ( toNames ( toFields ( group . satisfiedBy ) ) ) ; } } Assert . equals ( 0 , errors . length ( ) , "\nErrors were detected when analysing the @OneOf dependencies of '" + currentPath + "': \n" + errors ) ; }
Check that each group is satisfied by one and only one field .