public List < List < String > > getFilteredPolicy ( String sec , String ptype , int fieldIndex , String ... fieldValues ) { List < List < String >> res = new ArrayList <> ( ) ; for ( List < String > rule : model . get ( sec ) . get ( ptype ) . policy ) { boolean matched = true ; for ( int i = 0 ; i < fieldValues . length ; i ++ ) { String fieldValue = fieldValues [ i ] ; if ( ! fieldValue . equals ( "" ) && ! rule . get ( fieldIndex + i ) . equals ( fieldValue ) ) { matched = false ; break ; } } if ( matched ) { res . add ( rule ) ; } } return res ; }
getFilteredPolicy gets rules based on field filters from a policy .