public < T extends Model > LazyList < T > where ( String subquery , Object ... params ) { StringBuilder query ; if ( subquery . equals ( "*" ) ) { query = new StringBuilder ( ) ; } else { query = new StringBuilder ( subquery ) ; query . append ( " AND " ) ; } for ( int i = 0 ; i < scopes . size ( ) ; i ++ ) { String scope = scopes . get ( i ) ; if ( ! ModelDelegate . getScopes ( modelClass . getName ( ) ) . containsKey ( scope ) ) { throw new DBException ( String . format ( "Scope '%s' is not defined in model '%s'." , scope , modelClass . getName ( ) ) ) ; } String scopeQuery = ModelDelegate . getScopes ( modelClass . getName ( ) ) . get ( scope ) ; query . append ( scopeQuery ) ; if ( i < ( scopes . size ( ) - 1 ) ) { query . append ( " AND " ) ; } } return ModelDelegate . where ( ( Class < T > ) modelClass , query . toString ( ) , params ) ; }
Applies additional criteria to scopes defined in the model .