private Thing parseThing ( Kind kind , JSONObject data ) { // 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 ; } }
Parse the data into a thing if possible .