private RestType _tryConstructKey ( TableMetadata tm ) { for ( Filter f : filters ) if ( f . operator == StorageFilter . NOTEQUAL || f . operator == StorageFilter . NOTNULL || f . operator == StorageFilter . NULL || f . operator == StorageFilter . CONTAINS || f . operator == StorageFilter . NOTCONTAINS ) return RestType . LISTITEMS ; //because queryItems do not support notEqual, notNull, null, contains and notContains if ( tm . getSecondaryKeyName ( ) != null ) { if ( filters . size ( ) == 1 ) { Iterator < Filter > itr = filters . iterator ( ) ; Filter f = itr . next ( ) ; if ( f . itemName . equals ( tm . getPrimaryKeyName ( ) ) && f . operator == StorageFilter . EQUALS ) { this . key = new LinkedHashMap < String , Object > ( ) ; this . key . put ( "primary" , f . value ) ; filters . clear ( ) ; return RestType . QUERYITEMS ; } } else if ( filters . size ( ) == 2 ) { Object tValue = null ; Filter tFilter = null ; for ( Filter f : filters ) { if ( f . itemName . equals ( tm . getPrimaryKeyName ( ) ) && f . operator == StorageFilter . EQUALS ) { tValue = f . value ; } if ( f . itemName . equals ( tm . getSecondaryKeyName ( ) ) ) { tFilter = f ; } } if ( tValue != null && tFilter != null ) { filters . clear ( ) ; filters . add ( tFilter ) ; this . key = new LinkedHashMap < String , Object > ( ) ; this . key . put ( "primary" , tValue ) ; return RestType . QUERYITEMS ; } else { return RestType . LISTITEMS ; } } } else { if ( filters . size ( ) == 1 ) { Iterator < Filter > itr = filters . iterator ( ) ; Filter f = itr . next ( ) ; if ( f . itemName . equals ( tm . getPrimaryKeyName ( ) ) && f . operator == StorageFilter . EQUALS ) { return RestType . GETITEM ; } } } return RestType . LISTITEMS ; }
if returns null the rest type is listItems otherwise queryItems