public < T extends CanvasWriter > T getWriter ( Class < T > type , OauthToken oauthToken , Boolean serializeNulls ) { LOG . debug ( "Factory call to instantiate class: " + type . getName ( ) ) ; RestClient restClient = new RefreshingRestClient ( ) ; @ SuppressWarnings ( "unchecked" ) Class < T > concreteClass = ( Class < T > ) writerMap . get ( type ) ; if ( concreteClass == null ) { throw new UnsupportedOperationException ( "No implementation for requested interface found: " + type . getName ( ) ) ; } LOG . debug ( "got writer class: " + concreteClass ) ; try { Constructor < T > constructor = concreteClass . getConstructor ( String . class , Integer . class , OauthToken . class , RestClient . class , Integer . TYPE , Integer . TYPE , Integer . class , Boolean . class ) ; return constructor . newInstance ( canvasBaseUrl , CANVAS_API_VERSION , oauthToken , restClient , connectTimeout , readTimeout , null , serializeNulls ) ; } catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e ) { throw new UnsupportedOperationException ( "Unknown error instantiating the concrete API class: " + type . getName ( ) , e ) ; } }
Get a writer implementation to push data into Canvas while being able to control the behavior of blank values . If the serializeNulls parameter is set to true this writer will serialize null fields in the JSON being sent to Canvas . This is required if you want to explicitly blank out a value that is currently set to something .