@ Override public Boolean apply ( final RuleEntity ruleEntity , final ViolationEntity violationEntity ) { final List < Predicate < ViolationEntity > > predicates = newArrayList ( ) ; trimOptional ( ruleEntity . getAccountId ( ) ) . map ( WhitelistRulesEvaluator :: accountIsEqual ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getRegion ( ) ) . map ( WhitelistRulesEvaluator :: regionIsEqual ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getViolationTypeEntityId ( ) ) . map ( WhitelistRulesEvaluator :: violationTypeIdIsEqual ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getImageName ( ) ) . map ( WhitelistRulesEvaluator :: imageNameMatches ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getImageOwner ( ) ) . map ( WhitelistRulesEvaluator :: imageOwnerIsEqual ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getApplicationId ( ) ) . map ( WhitelistRulesEvaluator :: applicationIdIsEqual ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getApplicationVersion ( ) ) . map ( WhitelistRulesEvaluator :: applicationVersionIsEqual ) . ifPresent ( predicates :: add ) ; trimOptional ( ruleEntity . getMetaInfoJsonPath ( ) ) . map ( this :: metaInfoJsonPathExists ) . ifPresent ( predicates :: add ) ; final Optional < Predicate < ViolationEntity > > whiteListTest = predicates . stream ( ) . reduce ( Predicate :: and ) ; return whiteListTest . isPresent ( ) && whiteListTest . get ( ) . test ( violationEntity ) ; }
true if rule matches a violation and should be whitelisted .