protected void getPage ( final JSONObject params ) { if ( this . client == null ) client = BandwidthClient . getInstance ( ) ; try { final RestResponse response = client . get ( resourceUri , params ) ; final JSONArray array = Utils . response2JSONArray ( response ) ; for ( final Object obj : array ) { final E elem = clazz . getConstructor ( BandwidthClient . class , JSONObject . class ) . newInstance ( client , ( JSONObject ) obj ) ; add ( elem ) ; } // if anything comes back, reset the index if ( array . size ( ) > 0 ) this . index = 0 ; // set the next links this . setNextLink ( response . getNextLink ( ) ) ; this . setFirstLink ( response . getFirstLink ( ) ) ; this . setPreviousLink ( response . getPreviousLink ( ) ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } }
This method makes the API call to get the list value for the specified resource . It loads the return from the API into the arrayList updates the index if necessary and sets the new link values