question: private static Emoticon parseEmote ( JSONObject o , String urlTemplate , String channelRestriction ) { try { String url = urlTemplate ; String code = ( String ) o . get ( "code" ) ; String info = ( String ) o . get ( "channel" ) ; String id = ( String ) o . get ( "id" ) ; String imageType = null ; if ( o . get ( "imageType" ) instanceof String ) { imageType = ( String ) o . get ( "imageType" ) ; } if ( code == null || code . isEmpty ( ) || id == null || id . isEmpty ( ) ) { return null ; } Emoticon . Builder builder = new Emoticon . Builder ( Emoticon . Type . BTTV , code , url ) ; builder . setStream ( info ) ; builder . setLiteral ( true ) ; builder . setStringId ( id ) ; if ( channelRestriction != null ) { builder . addStreamRestriction ( channelRestriction ) ; } if ( imageType != null && imageType . equals ( "gif" ) ) { builder . setAnimated ( true ) ; } Object restriction = o . get ( "restrictions" ) ; if ( restriction != null && restriction instanceof JSONObject ) { JSONObject restrictions = ( JSONObject ) restriction ; for ( Object r : restrictions . keySet ( ) ) { boolean knownAndValid = addRestriction ( r , restrictions , builder ) ; if ( ! knownAndValid ) { return null ; } } } return builder . build ( ) ; } catch ( ClassCastException | NullPointerException ex ) { LOGGER . warning ( "BTTV: Error parsing emote: " + o + " [" + ex + "]" ) ; return null ; } }
target:  Parse a single emote from the given JSONObject.