signature:
public class MapReduceInputFormatWrapper { /** * Sets jobs input format to { @ link MapReduceInputFormatWrapper } and stores
 * supplied real { @ link InputFormat } class name in job configuration .
 * This configuration is read on the remote tasks to instantiate actual
 * InputFormat correctly . */
public static void setInputFormat ( Class < ? > realInputFormatClass , Job job ) { } }

implementation: job . setInputFormatClass ( MapReduceInputFormatWrapper . class ) ; setWrappedInputFormat ( realInputFormatClass , HadoopCompat . getConfiguration ( job ) ) ;


signature:
public class PigUtil { /** * Returns class using Pig ' s class loader . */
public static Class < ? > getClass ( String className ) { } }

implementation: try { return PigContext . resolveClassName ( className ) ; } catch ( IOException e ) { throw new RuntimeException ( "Could not instantiate " + className , e ) ; }


signature:
public class PigUtil { /** * Returns class using Pig ' s class loader .
 * If that fails tries { @ link Protobufs # getProtobufClass ( String ) } to
 * resolve the class */
public static Class < ? extends Message > getProtobufClass ( String protoClassName ) { } }

implementation:
try { // try Pig ' s loader
Class < ? > protoClass = getClass ( protoClassName ) ; return protoClass . asSubclass ( Message . class ) ; } catch ( RuntimeException e ) { // try normal loader first ( handles inner class ) .
return Protobufs . getProtobufClass ( protoClassName ) ; }


signature:
public class PigUtil { /** * Invokes the static { @ code getDescriptor } method of the given { @ link Message } class .
 * @ param protoClass the { @ link Message } class whose { @ link Descriptor } should be retrieved .
 * @ return the Descriptor instance for the given { @ link Message } class .
 * @ throws RuntimeException on any exception encountered during introspection of protoClass or
 * invocation of its static { @ code getDescriptor } method .
 * @ see Descriptors */
public static Descriptor getProtobufDescriptor ( Class < ? extends Message > protoClass ) { } }

implementation: try { return ( Descriptor ) protoClass . getMethod ( "getDescriptor" ) . invoke ( null ) ; } catch ( Exception e ) { throw new RuntimeException ( String . format ( "Failed to get Descriptor for Message type '%s'" , protoClass . getName ( ) ) , e ) ; }


signature:
public class PigUtil { /** * Returns TypeRef using Pig class loader . */
public static < T extends TBase < ? , ? > > TypeRef < T > getThriftTypeRef ( String thriftClassName ) { } }

implementation: return ThriftUtils . getTypeRef ( getClass ( thriftClassName ) ) ;


signature:
public class RCFileUtil { /** * reads { @ link ColumnarMetadata } stored in an RCFile .
 * @ throws IOException if metadata is not stored or in case of any other error . */
public static ColumnarMetadata readMetadata ( Configuration conf , Path rcfile ) throws IOException { } }

implementation:
Metadata metadata = null ; Configuration confCopy = new Configuration ( conf ) ; // set up conf to read all the columns
ColumnProjectionUtils . setFullyReadColumns ( confCopy ) ; RCFile . Reader reader = new RCFile . Reader ( rcfile . getFileSystem ( confCopy ) , rcfile , confCopy ) ; // ugly hack to get metadata . RCFile has to provide access to metata
try { Field f = RCFile . Reader . class . getDeclaredField ( "metadata" ) ; f . setAccessible ( true ) ; metadata = ( Metadata ) f . get ( reader ) ; } catch ( Throwable t ) { throw new IOException ( "Could not access metadata field in RCFile reader" , t ) ; } reader . close ( ) ; Text metadataKey = new Text ( COLUMN_METADATA_PROTOBUF_KEY ) ; if ( metadata == null || metadata . get ( metadataKey ) == null ) { throw new IOException ( "could not find ColumnarMetadata in " + rcfile ) ; } return ColumnarMetadata . parseFrom ( metadata . get ( metadataKey ) . getBytes ( ) ) ;


signature:
public class RCFileUtil { /** * Returns list of columns that need to be read from the RCFile .
 * These columns are the intersection of currently required columns and
 * columns stored in the file .
 * If any required column does not exist in the file , we need to read
 * the " unknown fields " column , which is usually the last last one . */
public static ArrayList < Integer > findColumnsToRead ( Configuration conf , List < Integer > currFieldIds , ColumnarMetadata storedInfo ) throws IOException { } }

implementation:
ArrayList < Integer > columnsToRead = Lists . newArrayList ( ) ; // first find the required fields
ArrayList < Integer > requiredFieldIds = Lists . newArrayList ( ) ; String reqFieldStr = conf . get ( RCFileUtil . REQUIRED_FIELD_INDICES_CONF , "" ) ; int numKnownFields = currFieldIds . size ( ) ; if ( reqFieldStr == null || reqFieldStr . equals ( "" ) ) { for ( int i = 0 ; i < numKnownFields ; i ++ ) { requiredFieldIds . add ( currFieldIds . get ( i ) ) ; } } else { for ( String str : reqFieldStr . split ( "," ) ) { int idx = Integer . valueOf ( str ) ; if ( idx < 0 || idx >= numKnownFields ) { throw new IOException ( "idx " + idx + " is out of range for known fields" ) ; } requiredFieldIds . add ( currFieldIds . get ( idx ) ) ; } } List < Integer > storedFieldIds = storedInfo . getFieldIdList ( ) ; for ( int i = 0 ; i < storedFieldIds . size ( ) ; i ++ ) { int sid = storedFieldIds . get ( i ) ; if ( sid > 0 && requiredFieldIds . contains ( sid ) ) { columnsToRead . add ( i ) ; } } // unknown fields : the required fields that are not listed in storedFieldIds
String unknownFields = "" ; for ( int rid : requiredFieldIds ) { if ( ! storedFieldIds . contains ( rid ) ) { unknownFields += " " + rid ; } } if ( unknownFields . length ( ) > 0 ) { int last = storedFieldIds . size ( ) - 1 ; LOG . info ( "unknown fields among required fileds :" + unknownFields ) ; if ( storedFieldIds . get ( last ) != - 1 ) { // not expected
throw new IOException ( "No unknowns column in in input" ) ; } columnsToRead . add ( last ) ; } LOG . info ( String . format ( "reading %d%s out of %d stored columns for %d required columns" , columnsToRead . size ( ) , ( unknownFields . length ( ) > 0 ? " (including unknowns column)" : "" ) , storedInfo . getFieldIdList ( ) . size ( ) , requiredFieldIds . size ( ) ) ) ; return columnsToRead ;


signature:
public class RCFileUtil { /** * Sets { @ link # REQUIRED _ FIELD _ INDICES _ CONF } to list of indices
 * if requiredFieldList is not null . */
public static void setRequiredFieldConf ( Configuration conf , RequiredFieldList requiredFieldList ) { } }

implementation:
// set required fields conf for RCFile [ Protobuf | Thrift ] input format
String value = "" ; if ( requiredFieldList != null ) { List < Integer > indices = Lists . newArrayList ( ) ; for ( RequiredField f : requiredFieldList . getFields ( ) ) { indices . add ( f . getIndex ( ) ) ; } value = Joiner . on ( "," ) . join ( indices ) ; } conf . set ( RCFileUtil . REQUIRED_FIELD_INDICES_CONF , value ) ;


signature:
public class LzoThriftB64LineOutputFormat { /** * Sets an internal configuration in jobConf so that remote Tasks
 * instantiate appropriate object for this generic class based on thriftClass */
public static < M extends TBase < ? , ? > > void setClassConf ( Class < M > thriftClass , Configuration jobConf ) { } }

implementation: ThriftUtils . setClassConf ( jobConf , LzoThriftB64LineOutputFormat . class , thriftClass ) ;


signature:
public class LzoBinaryB64LineRecordWriter { /** * for convenience */
public static < M extends TBase < ? , ? > > LzoBinaryB64LineRecordWriter < M , ThriftWritable < M > > newThriftWriter ( Class < M > tClass , DataOutputStream out ) { } }

implementation: return new LzoBinaryB64LineRecordWriter < M , ThriftWritable < M > > ( ThriftConverter . newInstance ( tClass ) , out ) ;


signature:
public class LzoBinaryB64LineRecordWriter { /** * for convenience */
public static < M extends Message > LzoBinaryB64LineRecordWriter < M , ProtobufWritable < M > > newProtobufWriter ( Class < M > tClass , DataOutputStream out ) { } }

implementation: return new LzoBinaryB64LineRecordWriter < M , ProtobufWritable < M > > ( ProtobufConverter . newInstance ( tClass ) , out ) ;


signature:
public class SubmissionsListingParser { /** * Parse JSON received from reddit into a list of submissions .
 * This parser expects the JSON to be of a listing of submissions ( ' links ' ) .
 * @ param jsonText JSON Text
 * @ return Parsed list of submissions
 * @ throws ParseException */
public List < Submission > parse ( String jsonText ) throws RedditParseException { } }

implementation:
// Parse to a list of things
List < Thing > things = this . parseGeneric ( jsonText ) ; // List of comment and submission mixed elements
List < Submission > submissions = new LinkedList < Submission > ( ) ; // Iterate over things
for ( Thing t : things ) { if ( t instanceof Submission ) { submissions . add ( ( Submission ) t ) ; } else { LOGGER . warn ( "Encountered an unexpected reddit thing (" + t . getKind ( ) . value ( ) + "), skipping it." ) ; } } // Return resulting comments list
return submissions ;


signature:
public class RedditHttpClient { /** * Execute the given HTTP request .
 * @ param request HTTP request
 * @ return Result , < i > null < / i > if failed */
private String executeHttpRequest ( HttpUriRequest request ) { } }

implementation:
try { // Attempt to do execute request
HttpResponse response = httpClient . execute ( request ) ; // Return response if successful
if ( response != null ) { return EntityUtils . toString ( response . getEntity ( ) , "UTF-8" ) ; } } catch ( UnsupportedEncodingException uee ) { LOGGER . warn ( "Unsupported Encoding Exception thrown in request" , uee ) ; } catch ( ClientProtocolException cpe ) { LOGGER . warn ( "Client Protocol Exception thrown in request" , cpe ) ; } catch ( IOException ioe ) { LOGGER . warn ( "I/O Exception thrown in request" , ioe ) ; } return null ;


signature:
public class RedditHttpClient { /** * Add authorization to the HTTP request .
 * @ param request HTTP request
 * @ param rToken Reddit token ( generally of the " bearer " type ) */
private void addAuthorization ( HttpRequest request , RedditToken rToken ) { } }

implementation: request . addHeader ( "Authorization" , rToken . getTokenType ( ) + " " + rToken . getAccessToken ( ) ) ;


signature:
public class RedditListingParser { /** * Validate that it is indeed the starting of a listing of reddit things .
 * @ param response Object returned by JSON parser
 * @ throws RedditRequestException If the response is not valid listing of reddit things */
public void validate ( Object response ) throws RedditParseException { } }

implementation:
// Check for null
if ( response == null ) { throw new RedditParseException ( ) ; } // Check it is a JSON response
if ( ! ( response instanceof JSONObject ) ) { throw new RedditParseException ( "not a JSON response" ) ; } // Cast to JSON object
JSONObject jsonResponse = ( ( JSONObject ) response ) ; // Check for error
if ( jsonResponse . get ( "error" ) != null ) { throw new RedditParseException ( JsonUtils . safeJsonToInteger ( jsonResponse . get ( "error" ) ) ) ; } // Check that data exists
if ( jsonResponse . get ( "data" ) == null && jsonResponse . get ( "json" ) == null ) { throw new RedditParseException ( "data is missing from listing" ) ; }


signature:
public class RedditListingParser { /** * Parse JSON received from reddit into a list of things .
 * This parser expects the JSON to be of a listing of things , and supports
 * the following things : < i > More < / i > , < i > Comment < / i > , < i > Submission < / i > , and < i > Subreddit < / i > . < br >
 * < br >
 * < i > Note : if it encounters an invalid element ( e . g . missing kind or data ) , it will
 * log a warning using SLF4J and would return null . < / i >
 * @ param jsonText JSON Text
 * @ param listingName Name of the listing name within the data
 * @ return Parsed list of things
 * @ throws ParseException */
public List < Thing > parseGeneric ( String jsonText , String listingName ) throws RedditParseException { } }

implementation:
try { // List of submissions
List < Thing > things = new LinkedList < Thing > ( ) ; // Send request to reddit server via REST client
Object response = JSON_PARSER . parse ( jsonText ) ; // Check for reddit error , can throw a RedditError
validate ( response ) ; // Cast to a JSON object
JSONObject object = ( JSONObject ) response ; // Get the array of children
JSONArray array = ( JSONArray ) ( ( JSONObject ) object . get ( "data" ) ) . get ( listingName ) ; // Iterate over array of children
for ( Object element : array ) { // Get the element
JSONObject data = ( JSONObject ) element ; // Make sure it is of the correct kind
String kindData = safeJsonToString ( data . get ( "kind" ) ) ; Object objData = data . get ( "data" ) ; // If no kind is given
if ( kindData == null ) { LOGGER . warn ( "Kind data missing, skipping it." ) ; // If no data is given
} else if ( objData == null || ! ( objData instanceof JSONObject ) ) { LOGGER . warn ( "Object data missing, skipping it." ) ; } else { // Attempt to match
Kind kind = Kind . match ( kindData ) ; // Parse the thing
Thing thing = parseThing ( kind , ( ( JSONObject ) data . get ( "data" ) ) ) ; // Show warning if failed
if ( thing == null ) { LOGGER . warn ( "Encountered invalid kind for a listing (" + kindData + "), skipping it." ) ; } else { things . add ( thing ) ; } } } // Finally return list of submissions
return things ; } catch ( ParseException pe ) { throw new RedditParseException ( pe ) ; }


signature:
public class RedditListingParser { /** * Parse the data into a thing if possible .
 * @ param kind Kind of data
 * @ param data Data for the thing
 * @ return The thing generated from the data , if failed < i > null < / i > */
private Thing parseThing ( Kind kind , JSONObject data ) { } }

implementation:
// For a comment
if ( kind == Kind . COMMENT ) { return new Comment ( data ) ; // For a submission
} else if ( kind == Kind . LINK ) { return new Submission ( data ) ; // For a subreddit
} else if ( kind == Kind . SUBREDDIT ) { return new Subreddit ( data ) ; // For a more
} else if ( kind == Kind . MORE ) { return new More ( data ) ; // In all other cases ( null , or of a different type )
} else { return null ; }


signature:
public class RedditScopeBuilder { /** * Build a string for the request . Called upon by
 * < i > RedditToken < / i > when requesting a token that
 * allows scope definition .
 * @ return String list of the scopes */
public String build ( ) { } }

implementation:
// Add each scope to the scope list
String s = "" ; for ( RedditScope scope : scopes ) { s += scope . value ( ) + RedditScope . SEPARATOR ; } // Remove final separator
if ( s . length ( ) > 0 ) { s = s . substring ( 0 , s . length ( ) - RedditScope . SEPARATOR . length ( ) ) ; } // Return scope list
return s ;


signature:
public class MixedListingParser { /** * Parse JSON received from reddit into a list of submissions and comments .
 * This parser expects the JSON to be of a listing of submissions and comments .
 * @ param jsonText JSON Text
 * @ return Parsed list of submissions
 * @ throws ParseException */
public List < MixedListingElement > parse ( String jsonText ) throws RedditParseException { } }

implementation:
// Parse to a list of things
List < Thing > things = this . parseGeneric ( jsonText ) ; // List of comment and submission mixed elements
List < MixedListingElement > mixedElements = new LinkedList < MixedListingElement > ( ) ; // Iterate over things
for ( Thing t : things ) { if ( t instanceof Comment ) { mixedElements . add ( ( Comment ) t ) ; } else if ( t instanceof Submission ) { mixedElements . add ( ( Submission ) t ) ; } else { LOGGER . warn ( "Encountered an unexpected reddit thing (" + t . getKind ( ) . value ( ) + "), skipping it." ) ; } } // Return result
return mixedElements ;


signature:
public class CommentsMoreParser { /** * Parse JSON received from reddit into a list of new additional comment tree elements .
 * This parser expects the JSON to be of a listing of comments and more ' s . < br >
 * < br >
 * < i > Note : this parsing can only be performed on listings of comments and more ' s , not on
 * a comment tree of a submission . < / i >
 * @ param jsonText JSON Text
 * @ return Parsed list of comments
 * @ throws ParseException
 * @ throws RedditRequestException */
public List < CommentTreeElement > parse ( String jsonText ) throws RedditParseException { } }

implementation:
try { // Parse JSON response
Object response = JSON_PARSER . parse ( jsonText ) ; // Validate main
this . validate ( response ) ; // Move to the main object
JSONObject main = ( JSONObject ) ( ( JSONObject ) response ) . get ( "json" ) ; // List of comment and more mixed elements
List < CommentTreeElement > elements = new LinkedList < CommentTreeElement > ( ) ; // If the main has data ( it can happen that it does not , when no comments identifiers were passed along )
if ( main . get ( "data" ) != null ) { // Parse to a list of things
List < Thing > things = this . parseGeneric ( main . toJSONString ( ) , "things" ) ; // Iterate over things
for ( Thing t : things ) { if ( t instanceof Comment ) { elements . add ( ( Comment ) t ) ; } else if ( t instanceof More ) { elements . add ( ( More ) t ) ; } else { LOGGER . warn ( "Encountered an unexpected reddit thing (" + t . getKind ( ) . value ( ) + "), skipping it." ) ; } } } // Return resulting element list
return elements ; } catch ( ParseException pe ) { throw new RedditParseException ( pe ) ; }


signature:
public class KeyValueFormatter { /** * Format a mapping of key - value pairs to a string , separating key from value using an
 * equals ( = ) sign , and separating pairs using an ampersand ( & ) sign .
 * @ param keyValueParameters Mapping of key - value pairs
 * @ param encodeUTF8 Whether or not the values should be encoded in UTF - 8
 * @ return Formatted string of key - value pairs ( e . g . " a = 1 & b = something " ) */
public static String format ( Map < String , String > keyValueParameters , boolean encodeUTF8 ) { } }

implementation:
// Key set
Set < String > keys = keyValueParameters . keySet ( ) ; // Iterate over keys
String paramsString = "" ; boolean start = true ; for ( String key : keys ) { // Add separation ampersand
if ( ! start ) { paramsString = paramsString . concat ( "&" ) ; } else { start = false ; } // Retrieve value
String value = keyValueParameters . get ( key ) ; // Encode key
if ( encodeUTF8 ) { try { value = URLEncoder . encode ( value , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { LOGGER . warn ( "Unsupported Encoding Exception thrown when encoding value" , e ) ; } } // Add key - value pair
paramsString = paramsString . concat ( key + "=" + value ) ; } // Return final parameter string
return paramsString ;


signature:
public class KeyValueFormatter { /** * Format a comma separated list of the given list .
 * @ param list List of strings
 * @ return Comma - separated list string ( e . g . " a , b , c , d " ) */
public static String formatCommaSeparatedList ( List < String > list ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( i != 0 ) { builder . append ( "," ) ; } builder . append ( list . get ( i ) ) ; } return builder . toString ( ) ;


signature:
public class RedditPoliteClient { /** * Wait if required . */
private void waitIfNeeded ( ) { } }

implementation:
// Calculate elapsed milliseconds
long elapsed = System . currentTimeMillis ( ) - lastReqTime ; // If enough time has elapsed , no need to wait
if ( elapsed >= interval ) { return ; } // If not enough time was elapsed , wait the remainder
long toWait = interval - elapsed ; try { Thread . sleep ( toWait ) ; } catch ( InterruptedException ie ) { LOGGER . warn ( "Interrupted Exception thrown while politely waiting for remainder of interval" , ie ) ; }


signature:
public class RedditOAuthAgent { /** * Generate the < i > code flow < / i > Uniform Resource Locator ( URI ) for a
 * reddit user to authorize your application . < br >
 * < br >
 * The user will , after authorization , receive a < i > code < / i > . This can be turned into
 * a < i > RedditToken < / i > using { @ link # token ( String ) } .
 * @ param scopeBuilder Authorization scope builder ( must not be < i > null < / i > )
 * @ param duration Duration that the token can last
 * @ return The URI users need to visit and retrieve the < i > code < / i > from
 * @ see { @ link # token ( String ) } for converting the < i > code < / i > into a usable < i > RedditToken < / i > */
public synchronized String generateCodeFlowURI ( RedditScopeBuilder scopeBuilder , RedditDuration duration ) { } }

implementation:
// Set parameters
Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( PARAM_CLIENT_ID , redditApp . getClientID ( ) ) ; params . put ( PARAM_RESPONSE_TYPE , "code" ) ; params . put ( PARAM_STATE , UUID . randomUUID ( ) . toString ( ) ) ; params . put ( PARAM_REDIRECT_URI , redditApp . getRedirectURI ( ) ) ; params . put ( PARAM_DURATION , duration . value ( ) ) ; params . put ( PARAM_SCOPE , scopeBuilder . build ( ) ) ; // Create URI
return REDDIT_AUTHORIZE + KeyValueFormatter . format ( params , true ) ;


signature:
public class RedditOAuthAgent { /** * Generate the < i > implicit flow < / i > Uniform Resource Locator ( URI ) for a
 * reddit user to authorize your application . < br >
 * < br >
 * The user will , after authorization , receive token information . This can be turned into
 * a < i > RedditToken < / i > using { @ link # tokenFromInfo ( String , String , long , String ) } .
 * @ param scopeBuilder Authorization scope builder ( must not be < i > null < / i > )
 * @ return The URI users need to visit and retrieve the < i > token information < / i > from
 * @ see { @ link # tokenFromInfo ( String , String , long , String ) } for converting the
 * < i > token information < / i > into < i > RedditToken < / i > */
public synchronized String generateImplicitFlowURI ( RedditScopeBuilder scopeBuilder ) { } }

implementation:
// Set parameters
Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( PARAM_CLIENT_ID , redditApp . getClientID ( ) ) ; params . put ( PARAM_RESPONSE_TYPE , "token" ) ; params . put ( PARAM_STATE , UUID . randomUUID ( ) . toString ( ) ) ; params . put ( PARAM_REDIRECT_URI , redditApp . getRedirectURI ( ) ) ; params . put ( PARAM_SCOPE , scopeBuilder . build ( ) ) ; // Create URI
return REDDIT_AUTHORIZE + KeyValueFormatter . format ( params , true ) ;


signature:
public class RedditOAuthAgent { /** * Add the basic authentication protocol to the OAuth request using
 * the credentials of the Reddit application provided .
 * @ param request OAuth request
 * @ param app Reddit application */
private void addBasicAuthentication ( OAuthClientRequest request , RedditApp app ) { } }

implementation: String authString = app . getClientID ( ) + ":" + app . getClientSecret ( ) ; String authStringEnc = DatatypeConverter . printBase64Binary ( authString . getBytes ( ) ) ; request . addHeader ( HEADER_AUTHORIZATION , "Basic " + authStringEnc ) ;


signature:
public class RedditOAuthAgent { /** * Token retrieval ( < i > code < / i > flow ) . < br >
 * < br >
 * Retrieve a token for a specific user , meaning that the token is < u > coupled to a user < / u > .
 * After it has expired , the token will no longer work . You must either request a new
 * token , or refresh it using { @ link # refreshToken ( RedditToken ) } .
 * @ param code One - time code received from the user , after manual authorization by that user
 * @ return Token ( associated with a user )
 * @ throws RedditOAuthException */
public synchronized RedditToken token ( String code ) throws RedditOAuthException { } }

implementation:
try { // Set general values of the request
OAuthClientRequest request = OAuthClientRequest . tokenProvider ( OAuthProviderType . REDDIT ) . setGrantType ( GrantType . AUTHORIZATION_CODE ) . setClientId ( redditApp . getClientID ( ) ) . setClientSecret ( redditApp . getClientSecret ( ) ) . setRedirectURI ( redditApp . getRedirectURI ( ) ) . setParameter ( PARAM_CODE , code ) . buildBodyMessage ( ) ; // Add the user agent
addUserAgent ( request ) ; // Add basic authentication
addBasicAuthentication ( request , redditApp ) ; // Return a wrapper controlled by jReddit
return new RedditToken ( oAuthClient . accessToken ( request ) ) ; } catch ( OAuthSystemException oase ) { throw new RedditOAuthException ( oase ) ; } catch ( OAuthProblemException oape ) { throw new RedditOAuthException ( oape ) ; }


signature:
public class RedditOAuthAgent { /** * Refresh token . < br >
 * < br >
 * This is < u > only < / u > possible for tokens retrieved through the < u > code flow < / u >
 * authorization and had their duration set to permanent . Tokens that do not have
 * a refresh _ token with them or are expired , will not be able to be refreshed .
 * In that case , a new one must be acquired .
 * @ param rToken Reddit token ( which needs to be refreshed )
 * @ return Whether the token was successfully refreshed
 * @ throws RedditOAuthException
 * @ see RedditToken # isRefreshable ( ) */
public synchronized boolean refreshToken ( RedditToken rToken ) throws RedditOAuthException { } }

implementation:
try { // Check whether the token can be refreshed
if ( rToken . isRefreshable ( ) ) { // Set general values of the request
OAuthClientRequest request = OAuthClientRequest . tokenProvider ( OAuthProviderType . REDDIT ) . setGrantType ( GrantType . REFRESH_TOKEN ) . setRefreshToken ( rToken . getRefreshToken ( ) ) . buildBodyMessage ( ) ; // Add the user agent
addUserAgent ( request ) ; // Add basic authentication
addBasicAuthentication ( request , redditApp ) ; // Return a wrapper controlled by jReddit
rToken . refresh ( oAuthClient . accessToken ( request ) ) ; return true ; } else { // The token cannot be refreshed
return false ; } } catch ( OAuthSystemException oase ) { throw new RedditOAuthException ( oase ) ; } catch ( OAuthProblemException oape ) { throw new RedditOAuthException ( oape ) ; }


signature:
public class RedditOAuthAgent { /** * Token retrieval ( < i > app - only < / i > flow ) . < br >
 * < br >
 * Retrieve a token for the < u > application - only < / u > , meaning that the
 * token is < u > not coupled to any user < / u > . The token is typically only
 * < u > valid for a short period of time < / u > ( at the moment of writing : 1 hour ) .
 * After it has expired , the token will no longer work . You must request a < u > new < / u >
 * token in that case . Refreshing an application - only token is not possible .
 * @ param confidential < i > True < / i > : confidential clients ( web apps / scripts ) not acting on
 * behalf of one or more logged out users . < i > False < / i > : installed app types ,
 * and other apps acting on behalf of one or more logged out users .
 * @ return Token ( not associated with a user )
 * @ throws RedditOAuthException */
public synchronized RedditToken tokenAppOnly ( boolean confidential ) throws RedditOAuthException { } }

implementation:
try { // Set general values of the request
TokenRequestBuilder builder = OAuthClientRequest . tokenProvider ( OAuthProviderType . REDDIT ) . setParameter ( PARAM_GRANT_TYPE , confidential ? GRANT_TYPE_CLIENT_CREDENTIALS : GRANT_TYPE_INSTALLED_CLIENT ) . setClientId ( redditApp . getClientID ( ) ) . setClientSecret ( redditApp . getClientSecret ( ) ) ; // If it is not acting on behalf of a unique client , a unique device identifier must be generated :
if ( ! confidential ) { builder = builder . setParameter ( PARAM_DEVICE_ID , UUID . randomUUID ( ) . toString ( ) ) ; } // Build the request
OAuthClientRequest request = builder . buildBodyMessage ( ) ; // Add the user agent
addUserAgent ( request ) ; // Add basic authentication
addBasicAuthentication ( request , redditApp ) ; // Return a wrapper controlled by jReddit
return new RedditToken ( oAuthClient . accessToken ( request ) ) ; } catch ( OAuthSystemException oase ) { throw new RedditOAuthException ( oase ) ; } catch ( OAuthProblemException oape ) { throw new RedditOAuthException ( oape ) ; }


signature:
public class RedditOAuthAgent { /** * Generate a token from information received using the < i > implicit grant flow < / i > . < br >
 * < br >
 * < b > WARNING : < / b > The expiration of the token is no longer very accurate . There is a delay
 * between the user receiving the token , and inputting it into this function . Beware that the
 * token might expire earlier than that the token reports it to .
 * @ param accessToken Access token
 * @ param tokenType Token type ( commonly " bearer " )
 * @ param expiresIn Expires in ( seconds )
 * @ param scope Scope
 * @ return < i > RedditToken < / i > generated using the given information . */
public synchronized RedditToken tokenFromInfo ( String accessToken , String tokenType , long expiresIn , String scope ) { } }

implementation: return new RedditToken ( accessToken , tokenType , expiresIn , scope ) ;


signature:
public class RedditToken { /** * Refresh this reddit token with data received from the new token .
 * @ param token Token received from a refresh request to reddit */
public void refresh ( OAuthJSONAccessTokenResponse token ) { } }

implementation: this . accessToken = token . getAccessToken ( ) ; this . expiration = currentTimeSeconds ( ) + token . getExpiresIn ( ) ; this . expirationSpan = token . getExpiresIn ( ) ; this . scopes = new RedditTokenCompleteScope ( token . getScope ( ) ) ; this . tokenType = token . getParam ( PARAM_TOKEN_TYPE ) ;


signature:
public class CommentTreeUtils { /** * Flatten the comment tree .
 * The original comment tree is not overwritten .
 * @ param cs List of comments that you get returned from one of the other methods here
 * @ return Flattened comment tree . */
public static List < CommentTreeElement > flattenCommentTree ( List < CommentTreeElement > commentTree ) { } }

implementation: List < CommentTreeElement > target = new ArrayList < CommentTreeElement > ( ) ; flattenCommentTree ( commentTree , target ) ; return target ;


signature:
public class CommentTreeUtils { /** * Flatten the comment tree .
 * The original comment tree is not overwritten .
 * @ param cs List of comments that you get returned from one of the other methods here
 * @ param target List in which to place the flattened comment tree . */
private static void flattenCommentTree ( List < CommentTreeElement > commentTree , List < CommentTreeElement > target ) { } }

implementation: for ( CommentTreeElement c : commentTree ) { target . add ( c ) ; if ( c instanceof Comment ) { flattenCommentTree ( ( ( Comment ) c ) . getReplies ( ) , target ) ; } }


signature:
public class CommentTreeUtils { /** * Get printable version of the given comment tree .
 * @ param cs List of comment tree elements
 * @ return Printable comment tree */
public static String printCommentTree ( List < CommentTreeElement > cs ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; for ( CommentTreeElement c : cs ) { builder . append ( printCommentTree ( c , 0 ) ) ; } return builder . toString ( ) ;


signature:
public class CommentTreeUtils { /** * Get printable version of a comment at a specific level . < br >
 * < br >
 * < i > Note : uses unsafe recursion < / i >
 * @ param c Comment
 * @ param level Level to place at
 * @ return Printable comment tree */
private static String printCommentTree ( CommentTreeElement c , int level ) { } }

implementation:
// Initialize empty buffer
StringBuilder builder = new StringBuilder ( ) ; // Add tabulation
for ( int i = 0 ; i < level ; i ++ ) { builder . append ( "\t" ) ; } // Comment string
builder . append ( c . toString ( ) ) ; builder . append ( "\n" ) ; // Iterate over children
if ( c instanceof Comment ) { for ( CommentTreeElement child : ( ( Comment ) c ) . getReplies ( ) ) { builder . append ( printCommentTree ( child , level + 1 ) ) ; } } // Return the buffer
return builder . toString ( ) ;


signature:
public class JsonUtils { /** * Safely converts an object into an integer
 * @ param obj The object to convert .
 * @ return an Integer representing the integer value of the Object ( null if the object cannot be converted to an Integer ) */
public static Integer safeJsonToInteger ( Object obj ) { } }

implementation: Integer intValue = null ; try { String str = safeJsonToString ( obj ) ; intValue = str != null ? Integer . parseInt ( str ) : null ; } catch ( NumberFormatException e ) { LOGGER . warn ( "Safe JSON conversion to Integer failed" , e ) ; } return intValue ;


signature:
public class JsonUtils { /** * Safely converts an object into an double
 * @ param obj The object to convert .
 * @ return a Double representing the double value of the Object ( null if the object cannot be converted to Double ) */
public static Double safeJsonToDouble ( Object obj ) { } }

implementation: Double doubleValue = null ; try { String str = safeJsonToString ( obj ) ; doubleValue = str != null ? Double . parseDouble ( str ) : null ; } catch ( NumberFormatException e ) { LOGGER . warn ( "Safe JSON conversion to Double failed" , e ) ; } return doubleValue ;


signature:
public class JsonUtils { /** * Safely converts an object into an boolean
 * @ param obj The object to convert .
 * @ return a Boolean representing the boolean value of the Object ( null only if the object was also null ) */
public static Boolean safeJsonToBoolean ( Object obj ) { } }

implementation: String str = safeJsonToString ( obj ) ; Boolean booleanValue = str != null ? Boolean . parseBoolean ( str ) : null ; return booleanValue ;


signature:
public class JsonUtils { /** * Safely converts an object into an long
 * @ param obj The object to convert .
 * @ return a Long representing the long value of the Object ( null if the object cannot be converted to Long ) */
public static Long safeJsonToLong ( Object obj ) { } }

implementation: Long longValue = null ; try { String str = safeJsonToString ( obj ) ; longValue = str != null ? Long . parseLong ( str ) : null ; } catch ( NumberFormatException e ) { LOGGER . warn ( "Safe JSON conversion to Long failed" , e ) ; } return longValue ;


signature:
public class CommentsListingParser { /** * Parse JSON received from reddit into a list of comments .
 * This parser expects the JSON to be of a listing of comments . < br >
 * < br >
 * < i > Note : this parsing can only be performed on listings of comments , not on
 * a comment tree of a submission . < / i >
 * @ param jsonText JSON Text
 * @ return Parsed list of comments
 * @ throws ParseException
 * @ throws RedditRequestException */
public List < Comment > parse ( String jsonText ) throws RedditParseException { } }

implementation:
// Parse to a list of things
List < Thing > things = this . parseGeneric ( jsonText ) ; // List of comment and submission mixed elements
List < Comment > comments = new LinkedList < Comment > ( ) ; // Iterate over things
for ( Thing t : things ) { if ( t instanceof Comment ) { comments . add ( ( Comment ) t ) ; } else { LOGGER . warn ( "Encountered an unexpected reddit thing (" + t . getKind ( ) . value ( ) + "), skipping it." ) ; } } // Return resulting comments list
return comments ;


signature:
public class FullSubmissionParser { /** * Parse JSON received from reddit into a full submission .
 * A full submissions means it has both ( a ) the submission , and ( b ) the comment tree .
 * @ param jsonText JSON Text
 * @ return Full submission
 * @ throws ParseException */
public FullSubmission parse ( String jsonText ) throws RedditParseException { } }

implementation:
try { // Parse JSON text
Object response = JSON_PARSER . parse ( jsonText ) ; // Validate response
validate ( response ) ; // Create submission ( casting with JSON is horrible )
JSONObject main = ( JSONObject ) ( ( JSONArray ) response ) . get ( 0 ) ; Submission submission = new Submission ( ( JSONObject ) ( ( JSONObject ) ( ( JSONArray ) ( ( JSONObject ) main . get ( "data" ) ) . get ( "children" ) ) . get ( 0 ) ) . get ( "data" ) ) ; // Create comment tree
JSONObject mainTree = ( JSONObject ) ( ( JSONArray ) response ) . get ( 1 ) ; List < CommentTreeElement > commentTree = parseRecursive ( mainTree ) ; // Return the set of submission and its comment tree
return new FullSubmission ( submission , commentTree ) ; } catch ( ParseException pe ) { throw new RedditParseException ( pe ) ; }


signature:
public class FullSubmissionParser { /** * Parse a JSON object consisting of comments and add them
 * to the already existing list of comments . This does NOT create
 * a new comment list .
 * @ param comments List of comments
 * @ param object JSON Object */
protected List < CommentTreeElement > parseRecursive ( JSONObject main ) throws RedditParseException { } }

implementation:
List < CommentTreeElement > commentTree = new ArrayList < CommentTreeElement > ( ) ; // Iterate over the comment tree results
JSONArray array = ( JSONArray ) ( ( JSONObject ) main . get ( "data" ) ) . get ( "children" ) ; for ( Object element : array ) { // Get the element
JSONObject data = ( JSONObject ) element ; // Make sure it is of the correct kind
String kind = safeJsonToString ( data . get ( "kind" ) ) ; // If it is a comment
if ( kind != null && kind . equals ( Kind . COMMENT . value ( ) ) ) { // Create comment
Comment comment = new Comment ( ( JSONObject ) data . get ( "data" ) ) ; // Retrieve replies
Object replies = ( ( JSONObject ) data . get ( "data" ) ) . get ( "replies" ) ; // If it is an JSON object
if ( replies instanceof JSONObject ) { comment . setReplies ( parseRecursive ( ( JSONObject ) replies ) ) ; // If there are no replies , end with an empty one
} else { comment . setReplies ( new ArrayList < CommentTreeElement > ( ) ) ; } // Add comment to the tree
commentTree . add ( comment ) ; } // If it is a more
if ( kind != null && kind . equals ( Kind . MORE . value ( ) ) ) { // Add to comment tree
commentTree . add ( new More ( ( JSONObject ) data . get ( "data" ) ) ) ; } } return commentTree ;


signature:
public class SubredditsListingParser { /** * Parse JSON received from reddit into a list of subreddits .
 * This parser expects the JSON to be of a listing of subreddits .
 * @ param jsonText JSON Text
 * @ return Parsed list of subreddits
 * @ throws ParseException */
public List < Subreddit > parse ( String jsonText ) throws RedditParseException { } }

implementation:
// Parse to a list of things
List < Thing > things = this . parseGeneric ( jsonText ) ; // List of comment and submission mixed elements
List < Subreddit > subreddits = new LinkedList < Subreddit > ( ) ; // Iterate over things
for ( Thing t : things ) { if ( t instanceof Subreddit ) { subreddits . add ( ( Subreddit ) t ) ; } else { LOGGER . warn ( "Encountered an unexpected reddit thing (" + t . getKind ( ) . value ( ) + "), skipping it." ) ; } } // Return resulting comments list
return subreddits ;


signature:
public class EnforceSignedRequestUtils { /** * signature returns the HmacSHA256 encoded signature used for signed Instagram requests
 * @ param endpoint The endpoint
 * @ param params The query parameters
 * @ param clientSecret The client application secret
 * @ return encoded signature String
 * @ throws InstagramException */
public static String signature ( String endpoint , Map < String , String > params , String clientSecret ) throws InstagramException { } }

implementation:
SecretKeySpec keySpec = new SecretKeySpec ( clientSecret . getBytes ( UTF_8 ) , HMAC_SHA256 ) ; // ensure we iterate through the keys in sorted order
List < String > values = new ArrayList < String > ( params . size ( ) ) ; for ( String key : MapUtils . getSortedKeys ( params ) ) { values . add ( String . format ( "%s=%s" , key , params . get ( key ) ) ) ; } // the sig string to sign in the form " endpoint | key1 = value1 | key2 = value2 | . . . . "
String sig = String . format ( "%s|%s" , endpoint , StringUtils . join ( values , '|' ) ) ; try { Mac mac = Mac . getInstance ( HMAC_SHA256 ) ; mac . init ( keySpec ) ; byte [ ] result = mac . doFinal ( sig . getBytes ( UTF_8 ) ) ; return Hex . encodeHexString ( result ) ; } catch ( NoSuchAlgorithmException e ) { throw new InstagramException ( "Invalid algorithm name!" , e ) ; } catch ( InvalidKeyException e ) { throw new InstagramException ( "Invalid key: " + clientSecret , e ) ; }


signature:
public class MapUtils { /** * Sorts a Map
 * @ param map unsorted map
 * @ return sorted map */
public static Map < String , String > sort ( Map < String , String > map ) { } }

implementation: Preconditions . checkNotNull ( map , "Cannot sort a null object." ) ; Map < String , String > sorted = new LinkedHashMap < String , String > ( ) ; for ( String key : getSortedKeys ( map ) ) { sorted . put ( key , map . get ( key ) ) ; } return sorted ;


signature:
public class MapUtils { /** * Form - urlDecodes and appends all keys from the source { @ link Map } to the
 * target { @ link Map }
 * @ param source Map from where the keys get copied and decoded
 * @ param target Map where the decoded keys are copied to */
public static void decodeAndAppendEntries ( Map < String , String > source , Map < String , String > target ) { } }

implementation: for ( Entry < String , String > entry : source . entrySet ( ) ) { target . put ( URLUtils . percentEncode ( entry . getKey ( ) ) , URLUtils . percentEncode ( entry . getValue ( ) ) ) ; }


signature:
public class InstagramOembed { /** * Returns information about the media associated with that link .
 * @ param url A short link , like http : / / instagr . am / p / BUG / .
 * @ return OembedInformation object
 * @ throws org . jinstagram . exceptions . InstagramException if any error occurs . */
public OembedInformation getOembedInformation ( String url ) throws InstagramException { } }

implementation: String apiMethod = String . format ( Methods . OEMBED_INFORMATION , url ) ; return createInstagramObject ( Verbs . GET , OembedInformation . class , apiMethod , null ) ;


signature:
public class InstagramOembed { /** * Create an Instagram object based on class - name and response .
 * @ param verbs HTTP State
 * @ param clazz
 * @ param methodName
 * @ param params
 * @ return
 * @ throws InstagramException */
private static < T > T createInstagramObject ( Verbs verbs , Class < T > clazz , String methodName , Map < String , String > params ) throws InstagramException { } }

implementation: Response response ; try { response = getApiResponse ( verbs , methodName , params ) ; } catch ( IOException e ) { throw new InstagramException ( "IOException while retrieving data" , e ) ; } if ( response . getCode ( ) >= 200 && response . getCode ( ) < 300 ) { return createObjectFromResponse ( clazz , response . getBody ( ) ) ; } throw handleInstagramError ( response ) ;


signature:
public class InstagramOembed { /** * Get response from Instagram .
 * @ param verb HTTP Verb
 * @ param methodName Instagram API Method
 * @ param params parameters which would be sent with the request .
 * @ return Response object . */
private static Response getApiResponse ( Verbs verb , String methodName , Map < String , String > params ) throws IOException { } }

implementation:
Response response ; String apiResourceUrl = Constants . OEMBED_URL + methodName ; OAuthRequest request = new OAuthRequest ( verb , apiResourceUrl ) ; // Additional parameters in url
if ( params != null ) { for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { if ( verb == Verbs . GET ) { request . addQuerystringParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } else { request . addBodyParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } } } response = request . send ( ) ; return response ;


signature:
public class InstagramOembed { /** * Creates an object from the JSON response and the class which the object would be mapped to .
 * @ param clazz a class instance
 * @ param response a JSON feed
 * @ return a object of type < T >
 * @ throws InstagramException if any error occurs . */
private static < T > T createObjectFromResponse ( Class < T > clazz , final String response ) throws InstagramException { } }

implementation: Gson gson = new Gson ( ) ; T object ; try { object = gson . fromJson ( response , clazz ) ; } catch ( Exception e ) { throw new InstagramException ( "Error parsing json to object type " + clazz . getName ( ) , e ) ; } return object ;


signature:
public class Preconditions { /** * Checks that at least one of object1 or object2 is not null
 * @ param object1 any object
 * @ param object2 any object
 * @ param errorMsg error message
 * @ throws IllegalArgumentException if both object1 and object2 are null */
public static void checkBothNotNull ( Object object1 , Object object2 , String errorMsg ) { } }

implementation: check ( ! ( object1 == null && object2 == null ) , errorMsg ) ;


signature:
public class Preconditions { /** * Checks that a string is not null or empty
 * @ param string any string
 * @ param errorMsg error message
 * @ throws IllegalArgumentException if the string is null or empty */
public static void checkEmptyString ( String string , String errorMsg ) { } }

implementation: check ( StringUtils . isNotBlank ( string ) , errorMsg ) ;


signature:
public class Preconditions { /** * Checks that a URL is valid
 * @ param url any string
 * @ param errorMsg error message */
public static void checkValidUrl ( String url , String errorMsg ) { } }

implementation: checkEmptyString ( url , errorMsg ) ; check ( isUrl ( url ) , errorMsg ) ;


signature:
public class Preconditions { /** * Checks that a URL is a valid OAuth callback
 * @ param url any string
 * @ param errorMsg error message */
public static void checkValidOAuthCallback ( String url , String errorMsg ) { } }

implementation: checkEmptyString ( url , errorMsg ) ; if ( url . toLowerCase ( ) . compareToIgnoreCase ( OAuthConstants . OUT_OF_BAND ) != 0 ) { check ( isUrl ( url ) , errorMsg ) ; }


signature:
public class Preconditions { /** * Checks that a string is a valid longitude or latitude value ( ' lat ' and ' lng ' )
 * as shown in < a href = " http : / / instagram . com / developer / realtime / " > Instagram Developer real time section < / a >
 * @ param latOrLong any string
 * @ param errorMsg error message */
public static void checkValidLatLong ( String latOrLong , String errorMsg ) { } }

implementation: checkEmptyString ( latOrLong , errorMsg ) ; check ( isLatLong ( latOrLong ) , errorMsg ) ;


signature:
public class Preconditions { /** * Check that a string is a valid radius value ( ' radius ' )
 * as shown in < a href = " http : / / instagram . com / developer / realtime / " > Instagram Developer real time section < / a >
 * @ param radiusString any string that is supposed to be a radius
 * @ param errorMsg error message */
public static void checkValidRadius ( String radiusString , String errorMsg ) { } }

implementation: checkEmptyString ( radiusString , errorMsg ) ; check ( isNumeric ( radiusString ) , errorMsg ) ;


signature:
public class InstagramAuthService { /** * Returns the fully configured { @ link OAuthService }
 * @ return fully configured { @ link OAuthService } */
public InstagramService build ( ) { } }

implementation: InstagramApi api = new InstagramApi ( ) ; OAuthConfig config ; Preconditions . checkEmptyString ( apiKey , "You must provide an api key" ) ; Preconditions . checkEmptyString ( apiSecret , "You must provide an api secret" ) ; config = new OAuthConfig ( apiKey , apiSecret , callback , scope , display ) ; if ( this . requestProxy != null ) { config . setRequestProxy ( this . requestProxy ) ; } return api . createService ( config ) ;


signature:
public class InstagramService { /** * { @ inheritDoc } */
public Token getAccessToken ( Verifier verifier ) { } }

implementation:
OAuthRequest request = new OAuthRequest ( api . getAccessTokenVerb ( ) , api . getAccessTokenEndpoint ( ) ) ; // Add the oauth parameter in the body
request . addBodyParameter ( OAuthConstants . CLIENT_ID , config . getApiKey ( ) ) ; request . addBodyParameter ( OAuthConstants . CLIENT_SECRET , config . getApiSecret ( ) ) ; request . addBodyParameter ( OAuthConstants . GRANT_TYPE , AUTHORIZATION_CODE ) ; request . addBodyParameter ( OAuthConstants . CODE , verifier . getValue ( ) ) ; request . addBodyParameter ( OAuthConstants . REDIRECT_URI , config . getCallback ( ) ) ; if ( config . hasScope ( ) ) { request . addBodyParameter ( OAuthConstants . SCOPE , config . getScope ( ) ) ; } if ( config . getDisplay ( ) != null ) { request . addBodyParameter ( OAuthConstants . DISPLAY , config . getDisplay ( ) ) ; } if ( config . getRequestProxy ( ) != null ) { request . setProxy ( config . getRequestProxy ( ) ) ; } Response response ; try { response = request . send ( ) ; } catch ( IOException e ) { throw new OAuthException ( "Could not get access token" , e ) ; } return api . getAccessTokenExtractor ( ) . extract ( response . getBody ( ) ) ;


signature:
public class InstagramService { /** * { @ inheritDoc } */
public void signRequest ( Token accessToken , OAuthRequest request ) { } }

implementation: request . addQuerystringParameter ( OAuthConstants . ACCESS_TOKEN , accessToken . getToken ( ) ) ;


signature:
public class InstagramService { /** * Return an Instagram object with enforced signed header */
@ Deprecated public InstagramClient getSignedHeaderInstagram ( Token accessToken , String ipAddress ) { } }

implementation: return new Instagram ( accessToken . getToken ( ) , config . getApiSecret ( ) , ipAddress ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserInfo ( java . lang . String ) */
@ Override public UserInfo getUserInfo ( String userId ) throws InstagramException { } }

implementation: logger . info ( "Getting user info for : " + userId ) ; Preconditions . checkEmptyString ( userId , USER_ID_CANNOT_BE_NULL_OR_EMPTY ) ; String apiMethod = format ( Methods . USERS_WITH_ID , userId ) ; return createInstagramObject ( Verbs . GET , UserInfo . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getCurrentUserInfo ( ) */
@ Override public UserInfo getCurrentUserInfo ( ) throws InstagramException { } }

implementation: LogHelper . logEntrance ( logger , "getCurrentUserInfo" , null ) ; logger . info ( "Getting current user info..." ) ; return createInstagramObject ( Verbs . GET , UserInfo . class , Methods . USERS_SELF , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserFeeds ( ) */
@ Override @ Deprecated public MediaFeed getUserFeeds ( ) throws InstagramException { } }

implementation: LogHelper . logEntrance ( logger , "getUserFeeds" , null ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . USERS_SELF_FEED , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserRecentMedia ( ) */
@ Override public MediaFeed getUserRecentMedia ( ) throws InstagramException { } }

implementation: LogHelper . logEntrance ( logger , "getUserRecentMedia" , null ) ; logger . info ( "Getting current user recent media..." ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . USERS_SELF_RECENT_MEDIA , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserRecentMedia ( int , java . lang . String , java . lang . String ) */
@ Override public MediaFeed getUserRecentMedia ( int count , String minId , String maxId ) throws InstagramException { } }

implementation: LogHelper . logEntrance ( logger , "getUserRecentMedia" , "[ count : " + count + ", minId : " + minId + ", maxId : " + maxId + "]" ) ; logger . info ( "Getting current user recent media..." ) ; Map < String , String > params = new HashMap < String , String > ( ) ; if ( maxId != null ) { params . put ( QueryParam . MAX_ID , String . valueOf ( maxId ) ) ; } if ( minId != null ) { params . put ( QueryParam . MIN_ID , String . valueOf ( minId ) ) ; } if ( count != 0 ) { params . put ( QueryParam . COUNT , String . valueOf ( count ) ) ; } return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . USERS_SELF_RECENT_MEDIA , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaFeed ( java . lang . String ) */
@ Override public MediaFeed getRecentMediaFeed ( String userId ) throws InstagramException { } }

implementation: Preconditions . checkEmptyString ( userId , USER_ID_CANNOT_BE_NULL_OR_EMPTY ) ; String methodName = format ( Methods . USERS_RECENT_MEDIA , userId ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , methodName , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaFeed ( java . lang . String , int , java . lang . String , java . lang . String , java . util . Date , java . util . Date ) */
@ Override public MediaFeed getRecentMediaFeed ( String userId , int count , String minId , String maxId , Date maxTimeStamp , Date minTimeStamp ) throws InstagramException { } }

implementation: Preconditions . checkEmptyString ( userId , USER_ID_CANNOT_BE_NULL_OR_EMPTY ) ; Map < String , String > params = new HashMap < String , String > ( ) ; if ( maxId != null ) { params . put ( QueryParam . MAX_ID , String . valueOf ( maxId ) ) ; } if ( minId != null ) { params . put ( QueryParam . MIN_ID , String . valueOf ( minId ) ) ; } if ( count != 0 ) { params . put ( QueryParam . COUNT , String . valueOf ( count ) ) ; } if ( maxTimeStamp != null ) { params . put ( QueryParam . MAX_TIMESTAMP , String . valueOf ( maxTimeStamp . getTime ( ) / 1000 ) ) ; } if ( minTimeStamp != null ) { params . put ( QueryParam . MIN_TIMESTAMP , String . valueOf ( minTimeStamp . getTime ( ) / 1000 ) ) ; } String methodName = format ( Methods . USERS_RECENT_MEDIA , userId ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , methodName , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaNextPage ( org . jinstagram . entity . common . Pagination ) */
@ Override public MediaFeed getRecentMediaNextPage ( Pagination pagination ) throws InstagramException { } }

implementation: PaginationHelper . Page page = PaginationHelper . parseNextUrl ( pagination , config . getApiURL ( ) ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , page . getMethodName ( ) , page . getRawMethodName ( ) , page . getQueryStringParams ( ) ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserFeedInfoNextPage ( org . jinstagram . entity . common . Pagination ) */
@ Override public UserFeed getUserFeedInfoNextPage ( Pagination pagination ) throws InstagramException { } }

implementation: PaginationHelper . Page page = PaginationHelper . parseNextUrl ( pagination , config . getApiURL ( ) ) ; return createInstagramObject ( Verbs . GET , UserFeed . class , page . getMethodName ( ) , page . getQueryStringParams ( ) ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserLikedMediaFeed ( ) */
@ Override public MediaFeed getUserLikedMediaFeed ( ) throws InstagramException { } }

implementation: return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . USERS_SELF_LIKED_MEDIA , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserLikedMediaFeed ( long , int ) */
@ Override public MediaFeed getUserLikedMediaFeed ( long maxLikeId , int count ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; if ( maxLikeId > 0 ) { params . put ( QueryParam . MAX_LIKE_ID , String . valueOf ( maxLikeId ) ) ; } if ( count > 0 ) { params . put ( QueryParam . COUNT , String . valueOf ( count ) ) ; } return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . USERS_SELF_LIKED_MEDIA , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchUser ( java . lang . String ) */
@ Override public UserFeed searchUser ( String query ) throws InstagramException { } }

implementation: Preconditions . checkNotNull ( query , "search query cannot be null." ) ; Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . SEARCH_QUERY , query ) ; return createInstagramObject ( Verbs . GET , UserFeed . class , Methods . USERS_SEARCH , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserFollowedByListNextPage ( java . lang . String , java . lang . String ) */
@ Override public UserFeed getUserFollowedByListNextPage ( String userId , String cursor ) throws InstagramException { } }

implementation: Preconditions . checkEmptyString ( userId , USER_ID_CANNOT_BE_NULL_OR_EMPTY ) ; Map < String , String > params = new HashMap < String , String > ( 1 ) ; if ( cursor != null ) params . put ( "cursor" , cursor ) ; String apiMethod = format ( Methods . USERS_ID_FOLLOWED_BY , userId ) ; return createInstagramObject ( Verbs . GET , UserFeed . class , apiMethod , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserRequestedBy ( ) */
@ Override public UserFeed getUserRequestedBy ( ) throws InstagramException { } }

implementation: return createInstagramObject ( Verbs . GET , UserFeed . class , Methods . USERS_SELF_REQUESTED_BY , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserRelationship ( java . lang . String ) */
@ Override public RelationshipFeed getUserRelationship ( String userId ) throws InstagramException { } }

implementation: Preconditions . checkEmptyString ( userId , USER_ID_CANNOT_BE_NULL_OR_EMPTY ) ; String apiMethod = format ( Methods . USERS_ID_RELATIONSHIP , userId ) ; return createInstagramObject ( Verbs . GET , RelationshipFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # setUserRelationship ( java . lang . String , org . jinstagram . model . Relationship ) */
@ Override public RelationshipFeed setUserRelationship ( String userId , Relationship relationship ) throws InstagramException { } }

implementation: Preconditions . checkEmptyString ( userId , USER_ID_CANNOT_BE_NULL_OR_EMPTY ) ; Preconditions . checkNotNull ( relationship , "relationship cannot be null." ) ; String apiMethod = format ( Methods . USERS_ID_RELATIONSHIP , userId ) ; Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . ACTION , relationship . toString ( ) ) ; return createInstagramObject ( Verbs . POST , RelationshipFeed . class , apiMethod , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getMediaInfo ( java . lang . String ) */
@ Override public MediaInfoFeed getMediaInfo ( String mediaId ) throws InstagramException { } }

implementation: Preconditions . checkNotNull ( mediaId , "mediaId cannot be null." ) ; String apiMethod = format ( Methods . MEDIA_BY_ID , mediaId ) ; return createInstagramObject ( Verbs . GET , MediaInfoFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getMediaInfoByShortcode ( java . lang . String ) */
@ Override public MediaInfoFeed getMediaInfoByShortcode ( String shortcode ) throws InstagramException { } }

implementation: Preconditions . checkNotNull ( shortcode , "shortcode cannot be null." ) ; String apiMethod = format ( Methods . MEDIA_BY_SHORTCODE , shortcode ) ; return createInstagramObject ( Verbs . GET , MediaInfoFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchMedia ( double , double , int ) */
@ Override public MediaFeed searchMedia ( double latitude , double longitude , int distance ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . LATITUDE , Double . toString ( latitude ) ) ; params . put ( QueryParam . LONGITUDE , Double . toString ( longitude ) ) ; params . put ( QueryParam . DISTANCE , String . valueOf ( distance ) ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . MEDIA_SEARCH , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchMedia ( double , double , java . util . Date , java . util . Date , int ) */
@ Override public MediaFeed searchMedia ( double latitude , double longitude , Date maxTimeStamp , Date minTimeStamp , int distance ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . LATITUDE , Double . toString ( latitude ) ) ; params . put ( QueryParam . LONGITUDE , Double . toString ( longitude ) ) ; if ( maxTimeStamp != null ) { params . put ( QueryParam . MAX_TIMESTAMP , String . valueOf ( maxTimeStamp . getTime ( ) / 1000 ) ) ; } if ( minTimeStamp != null ) { params . put ( QueryParam . MIN_TIMESTAMP , String . valueOf ( minTimeStamp . getTime ( ) / 1000 ) ) ; } params . put ( QueryParam . DISTANCE , String . valueOf ( distance ) ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . MEDIA_SEARCH , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getPopularMedia ( ) */
@ Override @ Deprecated public MediaFeed getPopularMedia ( ) throws InstagramException { } }

implementation: return createInstagramObject ( Verbs . GET , MediaFeed . class , Methods . MEDIA_POPULAR , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getMediaComments ( java . lang . String ) */
@ Override public MediaCommentsFeed getMediaComments ( String mediaId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . MEDIA_COMMENTS , mediaId ) ; return createInstagramObject ( Verbs . GET , MediaCommentsFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # setMediaComments ( java . lang . String , java . lang . String ) */
@ Override public MediaCommentResponse setMediaComments ( String mediaId , String text ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . TEXT , text ) ; String apiMethod = format ( Methods . MEDIA_COMMENTS , mediaId ) ; return createInstagramObject ( Verbs . POST , MediaCommentResponse . class , apiMethod , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # deleteMediaCommentById ( java . lang . String , java . lang . String ) */
@ Override public MediaCommentResponse deleteMediaCommentById ( String mediaId , String commentId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . DELETE_MEDIA_COMMENTS , mediaId , commentId ) ; return createInstagramObject ( Verbs . DELETE , MediaCommentResponse . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getUserLikes ( java . lang . String ) */
@ Override public LikesFeed getUserLikes ( String mediaId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . LIKES_BY_MEDIA_ID , mediaId ) ; return createInstagramObject ( Verbs . GET , LikesFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # setUserLike ( java . lang . String ) */
@ Override public LikesFeed setUserLike ( String mediaId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . LIKES_BY_MEDIA_ID , mediaId ) ; return createInstagramObject ( Verbs . POST , LikesFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # deleteUserLike ( java . lang . String ) */
@ Override public LikesFeed deleteUserLike ( String mediaId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . LIKES_BY_MEDIA_ID , mediaId ) ; return createInstagramObject ( Verbs . DELETE , LikesFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getTagInfo ( java . lang . String ) */
@ Override public TagInfoFeed getTagInfo ( String tagName ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . TAGS_BY_NAME , URLUtils . encodeURIComponent ( tagName ) ) ; String rawApiMethod = format ( Methods . TAGS_BY_NAME , tagName ) ; return createInstagramObject ( Verbs . GET , TagInfoFeed . class , apiMethod , rawApiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaTags ( java . lang . String , long ) */
@ Override public TagMediaFeed getRecentMediaTags ( String tagName , long count ) throws InstagramException { } }

implementation: return getRecentMediaTags ( tagName , null , null , count ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaFeedTags ( java . lang . String , long ) */
@ Override public MediaFeed getRecentMediaFeedTags ( String tagName , long count ) throws InstagramException { } }

implementation: return getRecentMediaFeedTags ( tagName , null , null , count ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaTags ( java . lang . String , java . lang . String , java . lang . String ) */
@ Override public TagMediaFeed getRecentMediaTags ( String tagName , String minTagId , String maxTagId ) throws InstagramException { } }

implementation: return getRecentMediaTags ( tagName , minTagId , maxTagId , 0 ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaFeedTags ( java . lang . String , java . lang . String , java . lang . String ) */
@ Override public MediaFeed getRecentMediaFeedTags ( String tagName , String minTagId , String maxTagId ) throws InstagramException { } }

implementation: return getRecentMediaFeedTags ( tagName , minTagId , maxTagId , 0 ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaTags ( java . lang . String , java . lang . String , java . lang . String , long ) */
@ Override public TagMediaFeed getRecentMediaTags ( String tagName , String minTagId , String maxTagId , long count ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; if ( ! StringUtils . isEmpty ( minTagId ) ) params . put ( QueryParam . MIN_TAG_ID , String . valueOf ( minTagId ) ) ; if ( ! StringUtils . isEmpty ( maxTagId ) ) params . put ( QueryParam . MAX_TAG_ID , String . valueOf ( maxTagId ) ) ; if ( count != 0 ) { params . put ( QueryParam . COUNT , String . valueOf ( count ) ) ; } String apiMethod = format ( Methods . TAGS_RECENT_MEDIA , URLUtils . encodeURIComponent ( tagName ) ) ; String rawApiMethod = format ( Methods . TAGS_RECENT_MEDIA , tagName ) ; return createInstagramObject ( Verbs . GET , TagMediaFeed . class , apiMethod , rawApiMethod , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaTagsByRegularIds ( java . lang . String , java . lang . String , java . lang . String ) */
@ Override @ Deprecated public TagMediaFeed getRecentMediaTagsByRegularIds ( String tagName , String minId , String maxId ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; if ( ! StringUtils . isEmpty ( minId ) ) params . put ( QueryParam . MIN_ID , String . valueOf ( minId ) ) ; if ( ! StringUtils . isEmpty ( maxId ) ) params . put ( QueryParam . MAX_ID , String . valueOf ( maxId ) ) ; String apiMethod = format ( Methods . TAGS_RECENT_MEDIA , URLUtils . encodeURIComponent ( tagName ) ) ; String rawApiMethod = format ( Methods . TAGS_RECENT_MEDIA , tagName ) ; return createInstagramObject ( Verbs . GET , TagMediaFeed . class , apiMethod , rawApiMethod , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchTags ( java . lang . String ) */
@ Override public TagSearchFeed searchTags ( String tagName ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . SEARCH_QUERY , tagName ) ; return createInstagramObject ( Verbs . GET , TagSearchFeed . class , Methods . TAGS_SEARCH , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getLocationInfo ( java . lang . String ) */
@ Override public LocationInfo getLocationInfo ( String locationId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . LOCATIONS_BY_ID , locationId ) ; return createInstagramObject ( Verbs . GET , LocationInfo . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaByLocation ( java . lang . String ) */
@ Override public MediaFeed getRecentMediaByLocation ( String locationId ) throws InstagramException { } }

implementation: String apiMethod = format ( Methods . LOCATIONS_RECENT_MEDIA_BY_ID , locationId ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , apiMethod , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaByLocation ( java . lang . String , java . lang . String , java . lang . String ) */
@ Override public MediaFeed getRecentMediaByLocation ( String locationId , String minId , String maxId ) throws InstagramException { } }

implementation: return getRecentMediaByLocation ( locationId , minId , maxId , null , null ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # getRecentMediaByLocation ( java . lang . String , java . lang . String , java . lang . String , java . util . Date , java . util . Date ) */
@ Override @ Deprecated public MediaFeed getRecentMediaByLocation ( String locationId , String minId , String maxId , Date maxTimeStamp , Date minTimeStamp ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; if ( maxTimeStamp != null ) { params . put ( QueryParam . MAX_TIMESTAMP , String . valueOf ( maxTimeStamp . getTime ( ) / 1000 ) ) ; } if ( minTimeStamp != null ) { params . put ( QueryParam . MIN_TIMESTAMP , String . valueOf ( minTimeStamp . getTime ( ) / 1000 ) ) ; } if ( minId != null ) params . put ( QueryParam . MIN_ID , minId ) ; if ( maxId != null ) params . put ( QueryParam . MAX_ID , maxId ) ; String apiMethod = format ( Methods . LOCATIONS_RECENT_MEDIA_BY_ID , locationId ) ; return createInstagramObject ( Verbs . GET , MediaFeed . class , apiMethod , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchLocation ( double , double ) */
@ Override public LocationSearchFeed searchLocation ( double latitude , double longitude ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . LATITUDE , Double . toString ( latitude ) ) ; params . put ( QueryParam . LONGITUDE , Double . toString ( longitude ) ) ; return createInstagramObject ( Verbs . GET , LocationSearchFeed . class , Methods . LOCATIONS_SEARCH , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchFoursquareVenue ( java . lang . String ) */
@ Override public LocationSearchFeed searchFoursquareVenue ( String foursquareId ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . FOURSQUARE_V2_ID , foursquareId ) ; return createInstagramObject ( Verbs . GET , LocationSearchFeed . class , Methods . LOCATIONS_SEARCH , params ) ;


signature:
public class InstagramBase { /** * / * ( non - Javadoc )
 * @ see org . jinstagram . InstagramClient # searchFacebookPlace ( java . lang . String ) */
@ Override public LocationSearchFeed searchFacebookPlace ( String facebookPlacesId ) throws InstagramException { } }

implementation: Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( QueryParam . FACEBOOK_PLACES_ID , facebookPlacesId ) ; return createInstagramObject ( Verbs . GET , LocationSearchFeed . class , Methods . LOCATIONS_SEARCH , params ) ;


signature:
public class InstagramBase { /** * Create a instagram object based on class - name and response .
 * This method must be used when signing requests if the methodName
 * could contain characters that required URI encoding
 * @ param verbs
 * HTTP State
 * @ param clazz
 * @ param methodName
 * @ param rawMethodName
 * @ param params
 * @ return
 * @ throws InstagramException */
protected < T extends InstagramObject > T createInstagramObject ( Verbs verbs , Class < T > clazz , String methodName , String rawMethodName , Map < String , String > params ) throws InstagramException { } }

implementation:
Response response ; String jsonResponseBody ; try { response = getApiResponse ( verbs , methodName , rawMethodName , params ) ; if ( config . isRetryOnServerError ( ) && wasResponseAnError ( response ) ) { Exception responseException = testResponseBody ( response ) ; int numberOfRetries = 2 ; int retryAttemptNumber = 0 ; while ( responseException != null && retryAttemptNumber < numberOfRetries ) { try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { /* ignore */
} // Retry request
logger . warn ( "(Retry #{}) Retrying request for {}" , retryAttemptNumber , response . getURL ( ) ) ; response = getApiResponse ( verbs , methodName , rawMethodName , params ) ; responseException = testResponseBody ( response ) ; retryAttemptNumber ++ ; } } jsonResponseBody = response . getBody ( ) ; LogHelper . prettyPrintJSONResponse ( logger , jsonResponseBody ) ; } catch ( IOException e ) { throw new InstagramException ( "IOException while retrieving data" , e ) ; } Map < String , String > responseHeaders = response . getHeaders ( ) ; if ( response . getCode ( ) >= 200 && response . getCode ( ) < 300 ) { T object = createObjectFromResponse ( clazz , jsonResponseBody ) ; object . setHeaders ( responseHeaders ) ; return object ; } throw handleInstagramError ( response . getCode ( ) , jsonResponseBody , responseHeaders ) ;


signature:
public class InstagramBase { /** * Create a instagram object based on class - name and response .
 * If using signed requests this is only safe if there are no characters
 * requiring URI encoding in the methodName
 * @ param verbs
 * HTTP State
 * @ param clazz
 * @ param methodName
 * @ param params
 * @ return
 * @ throws InstagramException */
protected < T extends InstagramObject > T createInstagramObject ( Verbs verbs , Class < T > clazz , String methodName , Map < String , String > params ) throws InstagramException { } }

implementation: return createInstagramObject ( verbs , clazz , methodName , methodName , params ) ;


signature:
public class InstagramBase { /** * Get response from Instagram .
 * @ param verb
 * HTTP Verb
 * @ param methodName
 * Instagram API Method
 * @ param rawMethodName
 * Unencoded Instagram API Method
 * @ param params
 * parameters which would be sent with the request .
 * @ return Response object . */
protected Response getApiResponse ( Verbs verb , String methodName , String rawMethodName , Map < String , String > params ) throws IOException { } }

implementation: Request request = request ( verb , methodName , rawMethodName , params ) ; logger . debug ( "Sending request to Instagram..." ) ; Response response = request . send ( ) ; return response ;


signature:
public class InstagramBase { /** * Configure the request with the connection settings of config
 * @ param request OAuthRequest object
 * @ param config InstagramConfig object */
public static void configureConnectionSettings ( final Request request , final InstagramConfig config ) { } }

implementation:
request . setConnectTimeout ( config . getConnectionTimeoutMills ( ) , TimeUnit . MILLISECONDS ) ; request . setReadTimeout ( config . getReadTimeoutMills ( ) , TimeUnit . MILLISECONDS ) ; // #51 Connection Keep Alive
request . setConnectionKeepAlive ( config . isConnectionKeepAlive ( ) ) ;


signature:
public class Request { /** * Get a { @ link Map } of the query string parameters .
 * @ return a map containing the query string parameters
 * @ throws OAuthException if the URL is not valid */
public Map < String , String > getQueryStringParams ( ) { } }

implementation: try { Map < String , String > params = new HashMap < String , String > ( ) ; String queryString = new URL ( url ) . getQuery ( ) ; params . putAll ( URLUtils . queryStringToMap ( queryString ) ) ; params . putAll ( this . querystringParams ) ; return params ; } catch ( MalformedURLException mue ) { throw new OAuthException ( "Malformed URL" , mue ) ; }


signature:
public class Request { /** * Returns the body of the request
 * @ return form encoded string
 * @ throws OAuthException if the charset chosen is not supported */
public String getBodyContents ( ) { } }

implementation: try { return new String ( getByteBodyContents ( ) , getCharset ( ) ) ; } catch ( UnsupportedEncodingException uee ) { throw new OAuthException ( "Unsupported Charset: " + charset , uee ) ; }


signature:
public class LogHelper { /** * Logs for entrance into every public methods with { @ link Level # DEBUG } .
 * @ param methodName The name of method entranced into .
 * @ param methodArguments The method arguments
 * @ param logger the logger instance */
public static void logEntrance ( Logger logger , String methodName , String methodArguments ) { } }

implementation: logger . debug ( String . format ( ENTRANCE_METHOD_PATTERN , methodName , methodArguments ) ) ;


signature:
public class LogHelper { /** * Logs for exit from every public methods with { @ link Level # DEBUG } .
 * @ param methodName The name of method existed from .
 * @ param returnValue the return value
 * @ param timeSpent the time spent
 * @ param logger the logger instance
 * @ param verboseLogging the control flag defining whether the detailed logging actions should be performed */
public static void logExit ( Logger logger , String methodName , String returnValue , long timeSpent ) { } }

implementation: logger . debug ( String . format ( EXIT_METHOD_PATTERN , methodName , returnValue , timeSpent ) ) ;


signature:
public class LogHelper { /** * Logs the given < code > Throwable < / code > with { @ link Level # ERROR } .
 * < / p > ; 2
 * @ param methodName The name of method where the exception occurs .
 * @ param e The < code > Throwable < / code > caught to be logged .
 * @ param timeSpent the time spent
 * @ param logger the logger instance
 * @ param verboseLogging the control flag defining whether the detailed logging actions should be performed */
public static void logException ( Logger logger , String methodName , Throwable e , long timeSpent ) { } }

implementation: logger . error ( String . format ( EXCEPTION_PATTERN , methodName , e . getClass ( ) . getSimpleName ( ) , e . getMessage ( ) ) ) ;


signature:
public class LogHelper { /** * Pretty print the JSON response in the logs
 * @ param logger the logger instance
 * @ param jsonString the json String which is to be pretty printed . */
public static void prettyPrintJSONResponse ( Logger logger , String jsonString ) { } }

implementation:
if ( logger . isDebugEnabled ( ) ) { // it can fail . . . on 404 it usually not a json
String s ; try { final JsonElement element = new JsonParser ( ) . parse ( jsonString ) ; s = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) . toJson ( element ) ; } catch ( Exception e ) { s = jsonString ; } logger . debug ( "Received JSON response from Instagram - " + s ) ; }


signature:
public class InstagramSubscription { /** * Configures the callback url
 * @ param callback The callback for your application
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription callback ( String callback ) { } }

implementation: Preconditions . checkValidUrl ( callback , "Invalid Callback Url" ) ; this . params . put ( Constants . CALLBACK_URL , callback ) ; return this ;


signature:
public class InstagramSubscription { /** * Configures the clientId
 * @ param clientId The clientId for your application
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription clientId ( String clientId ) { } }

implementation: Preconditions . checkEmptyString ( clientId , "Invalid 'clientId' key" ) ; this . params . put ( Constants . CLIENT_ID , clientId ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the clientSecret
 * @ param clientSecret The clientSecret for your application
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription clientSecret ( String clientSecret ) { } }

implementation: Preconditions . checkEmptyString ( clientSecret , "Invalid 'clientSecret' key" ) ; this . params . put ( Constants . CLIENT_SECRET , clientSecret ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the subscription type
 * @ param type The subscription type for your usage
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription object ( SubscriptionType type ) { } }

implementation: this . params . put ( Constants . SUBSCRIPTION_TYPE , type . toString ( ) ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the verifyToken for the subscription
 * @ param verifyToken The token for the subscription
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription verifyToken ( String verifyToken ) { } }

implementation: Preconditions . checkEmptyString ( verifyToken , "Invalid 'verifyToken' key" ) ; this . params . put ( Constants . VERIFY_TOKEN , verifyToken ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the aspect for the subscription
 * @ param aspect The aspect of the subscription
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription aspect ( String aspect ) { } }

implementation: Preconditions . checkEmptyString ( aspect , "Invalid 'aspect' key" ) ; this . params . put ( Constants . ASPECT , aspect ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the latitude for geography subscription
 * @ param latitude The latitude for geography subscription
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription latitute ( String latitude ) { } }

implementation: Preconditions . checkValidLatLong ( latitude , "Invalid 'lat' key" ) ; this . params . put ( Constants . LATITUDE , latitude ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the longitude for geography subscription
 * @ param longitude The longitude for geography subscription
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription longitude ( String longitude ) { } }

implementation: Preconditions . checkValidLatLong ( longitude , "Invalid 'lng' key" ) ; this . params . put ( Constants . LONGITUDE , longitude ) ; return this ;


signature:
public class InstagramSubscription { /** * Configure the radius for geography subscription
 * @ param radius The radius for geography subscription in metre
 * @ return the { @ link InstagramSubscription } instance for method chaining */
public InstagramSubscription radius ( String radius ) { } }

implementation: Preconditions . checkValidRadius ( radius , "Invalid 'radius' key" ) ; this . params . put ( Constants . RADIUS , radius ) ; return this ;


signature:
public class InstagramSubscription { /** * Creates a subscription with the current state of this instance .
 * The { @ link SubscriptionResponse } holds the result of the subscription such as the identifier
 * of the subscription that can be used later to { @ linkplain # deleteSubscription ( String ) delete it } .
 * @ return the result of the subscription
 * @ throws InstagramException */
public SubscriptionResponse createSubscription ( ) throws InstagramException { } }

implementation: String callback = params . get ( Constants . CALLBACK_URL ) ; if ( callback == null ) { callback = "" ; } Preconditions . checkEmptyString ( callback , "You must provide a callback url" ) ; final OAuthRequest request = prepareOAuthRequest ( Verbs . POST ) ; request . addBodyParameter ( Constants . ASPECT , "media" ) ; for ( Map . Entry < String , String > entry : this . params . entrySet ( ) ) { request . addBodyParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } try { final Response response = request . send ( ) ; return getSubscriptionResponse ( response . getBody ( ) ) ; } catch ( IOException e ) { throw new InstagramException ( "Failed to create subscription" , e ) ; }


signature:
public class InstagramSubscription { /** * Deletes a subscription with the specified identifier .
 * @ param id the id of the subscription to remove */
public SubscriptionResponse deleteSubscription ( String id ) throws InstagramException { } }

implementation: final OAuthRequest request = prepareOAuthRequest ( Verbs . DELETE ) ; request . addQuerystringParameter ( "id" , id ) ; try { final Response response = request . send ( ) ; return getSubscriptionResponse ( response . getBody ( ) ) ; } catch ( IOException e ) { throw new InstagramException ( "Failed to delete subscription with id [" + id + "]" , e ) ; }


signature:
public class InstagramSubscription { /** * Deletes all the known subscription .
 * @ return the response of this request , holding mainly the code */
public SubscriptionResponse deleteAllSubscription ( ) throws InstagramException { } }

implementation: final OAuthRequest request = prepareOAuthRequest ( Verbs . DELETE ) ; request . addQuerystringParameter ( Constants . SUBSCRIPTION_TYPE , "all" ) ; try { final Response response = request . send ( ) ; return getSubscriptionResponse ( response . getBody ( ) ) ; } catch ( IOException e ) { throw new InstagramException ( "Failed to delete all subscriptions" , e ) ; }


signature:
public class InstagramSubscription { /** * Returns the currently active subscription .
 * @ return the active subscription */
public SubscriptionsListResponse getSubscriptionList ( ) throws InstagramException { } }

implementation: final OAuthRequest request = prepareOAuthRequest ( Verbs . GET ) ; try { final Response response = request . send ( ) ; return getSubscriptionsListResponse ( response . getBody ( ) ) ; } catch ( IOException e ) { throw new InstagramException ( "Failed to get subscription list" , e ) ; }


signature:
public class URLUtils { /** * Encodes the passed String as UTF - 8 using an algorithm that ' s compatible
 * with JavaScript ' s < code > encodeURIComponent < / code > function . Returns
 * < code > null < / code > if the String is < code > null < / code > .
 * @ param s The String to be encoded
 * @ return the encoded String
 * ( from : http : / / stackoverflow . com / questions / 607176 / java - equivalent - to - javascripts - encodeuricomponent - that - produces - identical - outpu ) */
public static String encodeURIComponent ( String s ) { } }

implementation:
String result = null ; try { result = URLEncoder . encode ( s , "UTF-8" ) . replaceAll ( "\\+" , "%20" ) . replaceAll ( "\\%21" , "!" ) . replaceAll ( "\\%27" , "'" ) . replaceAll ( "\\%28" , "(" ) . replaceAll ( "\\%29" , ")" ) . replaceAll ( "\\%7E" , "~" ) ; } // This exception should never occur .
catch ( UnsupportedEncodingException e ) { result = s ; } return result ;


signature:
public class URLUtils { /** * Decodes the passed - in String as UTF - 8 using an algorithm that ' s compatible
 * with JavaScript ' s < code > decodeURIComponent < / code > function . Returns
 * < code > null < / code > if the String is < code > null < / code > .
 * @ param s The String to be decoded
 * @ return the decoded String
 * ( from : http : / / stackoverflow . com / questions / 607176 / java - equivalent - to - javascripts - encodeuricomponent - that - produces - identical - outpu ) */
public static String decodeURIComponent ( String s ) { } }

implementation:
String result = null ; try { result = URLDecoder . decode ( s , "UTF-8" ) ; } // This exception should never occur .
catch ( UnsupportedEncodingException e ) { result = s ; } return result ;


signature:
public class URLUtils { /** * Turns a map into a form - urlencoded string
 * @ param map any map
 * @ return form - url - encoded string */
public static String formURLEncodeMap ( Map < String , String > map ) { } }

implementation: Preconditions . checkNotNull ( map , "Cannot url-encode a null object" ) ; return ( map . size ( ) <= 0 ) ? EMPTY_STRING : doFormUrlEncode ( map ) ;


signature:
public class URLUtils { /** * Percent encodes a string
 * @ param string plain string
 * @ return percent encoded string */
public static String percentEncode ( String string ) { } }

implementation: String encoded = formURLEncode ( string ) ; for ( EncodingRule rule : ENCODING_RULES ) { encoded = rule . apply ( encoded ) ; } return encoded ;


signature:
public class URLUtils { /** * Translates a string into application / x - www - form - urlencoded format
 * @ param plain
 * @ return form - urlencoded string */
public static String formURLEncode ( String string ) { } }

implementation: Preconditions . checkNotNull ( string , "Cannot encode null string" ) ; try { return URLEncoder . encode ( string , UTF_8 ) ; } catch ( UnsupportedEncodingException uee ) { throw new IllegalStateException ( ERROR_MSG , uee ) ; }


signature:
public class URLUtils { /** * Decodes a application / x - www - form - urlencoded string
 * @ param string form - urlencoded string
 * @ return plain string */
public static String formURLDecode ( String string ) { } }

implementation: Preconditions . checkNotNull ( string , "Cannot decode null string" ) ; try { return URLDecoder . decode ( string , UTF_8 ) ; } catch ( UnsupportedEncodingException uee ) { throw new IllegalStateException ( ERROR_MSG , uee ) ; }


signature:
public class URLUtils { /** * Append given parameters to the query string of the url
 * @ param url the url to append parameters to
 * @ param params any map
 * @ return new url with parameters on query string */
public static String appendParametersToQueryString ( String url , Map < String , String > params ) { } }

implementation: Preconditions . checkNotNull ( url , "Cannot append to null URL" ) ; String queryString = URLUtils . formURLEncodeMap ( params ) ; if ( queryString . equals ( EMPTY_STRING ) ) { return url ; } else { url += ( url . indexOf ( QUERY_STRING_SEPARATOR ) != - 1 ) ? PARAM_SEPARATOR : QUERY_STRING_SEPARATOR ; url += queryString ; return url ; }


signature:
public class URLUtils { /** * Concats a key - value map into a querystring - like String
 * @ param params key - value map
 * @ return querystring - like String */
public static String concatSortedPercentEncodedParams ( Map < String , String > params ) { } }

implementation: StringBuilder result = new StringBuilder ( ) ; for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { result . append ( entry . getKey ( ) ) . append ( PAIR_SEPARATOR ) ; result . append ( entry . getValue ( ) ) . append ( PARAM_SEPARATOR ) ; } return result . toString ( ) . substring ( 0 , result . length ( ) - 1 ) ;


signature:
public class URLUtils { /** * Parses and form - urldecodes a querystring - like string into a map
 * @ param queryString querystring - like String
 * @ return a map with the form - urldecoded parameters */
public static Map < String , String > queryStringToMap ( String queryString ) { } }

implementation: Map < String , String > result = new HashMap < String , String > ( ) ; if ( ( queryString != null ) && ( queryString . length ( ) > 0 ) ) { for ( String param : queryString . split ( PARAM_SEPARATOR ) ) { String pair [ ] = param . split ( PAIR_SEPARATOR ) ; String key = formURLDecode ( pair [ 0 ] ) ; String value = ( pair . length > 1 ) ? formURLDecode ( pair [ 1 ] ) : EMPTY_STRING ; result . put ( key , value ) ; } } return result ;


signature:
public class InstagramErrorResponse { /** * Throw instagram exception to the client
 * @ throws InstagramException */
public void throwException ( ) throws InstagramException { } }

implementation: if ( errorMeta != null ) { String msg = errorMeta . getErrorType ( ) + ": " + errorMeta . getErrorMessage ( ) ; switch ( errorMeta . getCode ( ) ) { case 400 : throw new InstagramBadRequestException ( errorMeta . getErrorType ( ) , msg , this . headers ) ; case 429 : throw new InstagramRateLimitException ( errorMeta . getErrorType ( ) , msg , this . headers ) ; default : throw new InstagramException ( errorMeta . getErrorType ( ) , msg , this . headers ) ; } } else { throw new InstagramException ( "No metadata found in response" , this . headers ) ; }


signature:
public class InstagramErrorResponse { /** * Parse the specified json holding a response object . Instagram has two ways of
 * specifying an error : either a meta attribute is set or the body of the
 * response is a meta object itself .
 * @ param gson the gson instance to use
 * @ param json the json response content
 * @ return the InstagramErrorResponse object */
public static InstagramErrorResponse parse ( Gson gson , String json ) { } }

implementation:
JsonElement jsonElement = gson . fromJson ( json , JsonElement . class ) ; JsonElement metaMember = null ; if ( jsonElement != null ) { metaMember = jsonElement . getAsJsonObject ( ) . get ( "meta" ) ; } final Meta meta ; if ( metaMember != null ) { meta = gson . fromJson ( metaMember , Meta . class ) ; } else { meta = gson . fromJson ( jsonElement , Meta . class ) ; } // Validate meta
if ( meta . getCode ( ) != 0 && meta . getErrorType ( ) != null ) { return new InstagramErrorResponse ( meta ) ; } else { return new InstagramErrorResponse ( null ) ; }


signature:
public class DNS { /** * 15ms */
private static InetAddress [ ] getByCommand ( ) { } }

implementation:
try { Process process = Runtime . getRuntime ( ) . exec ( "getprop" ) ; InputStream inputStream = process . getInputStream ( ) ; LineNumberReader lnr = new LineNumberReader ( new InputStreamReader ( inputStream ) ) ; String line = null ; ArrayList < InetAddress > servers = new ArrayList < InetAddress > ( 5 ) ; while ( ( line = lnr . readLine ( ) ) != null ) { int split = line . indexOf ( "]: [" ) ; if ( split == - 1 ) { continue ; } String property = line . substring ( 1 , split ) ; String value = line . substring ( split + 4 , line . length ( ) - 1 ) ; if ( property . endsWith ( ".dns" ) || property . endsWith ( ".dns1" ) || property . endsWith ( ".dns2" ) || property . endsWith ( ".dns3" ) || property . endsWith ( ".dns4" ) ) { // normalize the address
InetAddress ip = InetAddress . getByName ( value ) ; if ( ip == null ) continue ; value = ip . getHostAddress ( ) ; if ( value == null ) continue ; if ( value . length ( ) == 0 ) continue ; servers . add ( ip ) ; } } if ( servers . size ( ) > 0 ) { return servers . toArray ( new InetAddress [ servers . size ( ) ] ) ; } } catch ( IOException e ) { Logger . getLogger ( "AndroidDnsServer" ) . log ( Level . WARNING , "Exception in findDNSByExec" , e ) ; } return null ;


signature:
public class DNS { /** * 1ms */
private static InetAddress [ ] getByReflection ( ) { } }

implementation:
try { Class < ? > SystemProperties = Class . forName ( "android.os.SystemProperties" ) ; Method method = SystemProperties . getMethod ( "get" , new Class < ? > [ ] { String . class } ) ; ArrayList < InetAddress > servers = new ArrayList < InetAddress > ( 5 ) ; for ( String propKey : new String [ ] { "net.dns1" , "net.dns2" , "net.dns3" , "net.dns4" } ) { String value = ( String ) method . invoke ( null , propKey ) ; if ( value == null ) continue ; if ( value . length ( ) == 0 ) continue ; InetAddress ip = InetAddress . getByName ( value ) ; if ( ip == null ) continue ; value = ip . getHostAddress ( ) ; if ( value == null ) continue ; if ( value . length ( ) == 0 ) continue ; if ( servers . contains ( ip ) ) continue ; servers . add ( ip ) ; } if ( servers . size ( ) > 0 ) { return servers . toArray ( new InetAddress [ servers . size ( ) ] ) ; } } catch ( Exception e ) { // we might trigger some problems this way
Logger . getLogger ( "AndroidDnsServer" ) . log ( Level . WARNING , "Exception in findDNSByReflection" , e ) ; } return null ;


signature:
public class BaseTick { /** * Adds a trade at the end of tick period .
 * @ param tradeVolume the traded volume
 * @ param tradePrice the price */
public void addTrade ( Decimal tradeVolume , Decimal tradePrice ) { } }

implementation: if ( openPrice == null ) { openPrice = tradePrice ; } closePrice = tradePrice ; if ( maxPrice == null ) { maxPrice = tradePrice ; } else { maxPrice = maxPrice . isLessThan ( tradePrice ) ? tradePrice : maxPrice ; } if ( minPrice == null ) { minPrice = tradePrice ; } else { minPrice = minPrice . isGreaterThan ( tradePrice ) ? tradePrice : minPrice ; } volume = volume . plus ( tradeVolume ) ; amount = amount . plus ( tradeVolume . multipliedBy ( tradePrice ) ) ; trades ++ ;