signature:
public class SVGGraphics2D { /** * Draws the specified glyph vector at the location { @ code ( x , y ) } .
 * @ param g the glyph vector ( { @ code null } not permitted ) .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate . */
@ Override public void drawGlyphVector ( GlyphVector g , float x , float y ) { } }

implementation: fill ( g . getOutline ( x , y ) ) ;


signature:
public class SVGGraphics2D { /** * Applies the translation { @ code ( tx , ty ) } .
 * @ param tx the x - translation .
 * @ param ty the y - translation . */
@ Override public void translate ( double tx , double ty ) { } }

implementation: AffineTransform t = getTransform ( ) ; t . translate ( tx , ty ) ; setTransform ( t ) ;


signature:
public class SVGGraphics2D { /** * Applies a rotation ( anti - clockwise ) about { @ code ( 0 , 0 ) } .
 * @ param theta the rotation angle ( in radians ) . */
@ Override public void rotate ( double theta ) { } }

implementation: AffineTransform t = getTransform ( ) ; t . rotate ( theta ) ; setTransform ( t ) ;


signature:
public class SVGGraphics2D { /** * Applies a rotation ( anti - clockwise ) about { @ code ( x , y ) } .
 * @ param theta the rotation angle ( in radians ) .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate . */
@ Override public void rotate ( double theta , double x , double y ) { } }

implementation: translate ( x , y ) ; rotate ( theta ) ; translate ( - x , - y ) ;


signature:
public class SVGGraphics2D { /** * Applies a scale transformation .
 * @ param sx the x - scaling factor .
 * @ param sy the y - scaling factor . */
@ Override public void scale ( double sx , double sy ) { } }

implementation: AffineTransform t = getTransform ( ) ; t . scale ( sx , sy ) ; setTransform ( t ) ;


signature:
public class SVGGraphics2D { /** * Applies this transform to the existing transform by concatenating it .
 * @ param t the transform ( { @ code null } not permitted ) . */
@ Override public void transform ( AffineTransform t ) { } }

implementation: AffineTransform tx = getTransform ( ) ; tx . concatenate ( t ) ; setTransform ( tx ) ;


signature:
public class SVGGraphics2D { /** * Sets the transform .
 * @ param t the new transform ( { @ code null } permitted , resets to the
 * identity transform ) .
 * @ see # getTransform ( ) */
@ Override public void setTransform ( AffineTransform t ) { } }

implementation: if ( t == null ) { this . transform = new AffineTransform ( ) ; } else { this . transform = new AffineTransform ( t ) ; } this . clipRef = null ;


signature:
public class SVGGraphics2D { /** * Returns { @ code true } if the rectangle ( in device space ) intersects
 * with the shape ( the interior , if { @ code onStroke } is { @ code false } ,
 * otherwise the stroked outline of the shape ) .
 * @ param rect a rectangle ( in device space ) .
 * @ param s the shape .
 * @ param onStroke test the stroked outline only ?
 * @ return A boolean . */
@ Override public boolean hit ( Rectangle rect , Shape s , boolean onStroke ) { } }

implementation: Shape ts ; if ( onStroke ) { ts = this . transform . createTransformedShape ( this . stroke . createStrokedShape ( s ) ) ; } else { ts = this . transform . createTransformedShape ( s ) ; } if ( ! rect . getBounds2D ( ) . intersects ( ts . getBounds2D ( ) ) ) { return false ; } Area a1 = new Area ( rect ) ; Area a2 = new Area ( ts ) ; a1 . intersect ( a2 ) ; return ! a1 . isEmpty ( ) ;


signature:
public class SVGGraphics2D { /** * Returns the user clipping region . The initial default value is
 * { @ code null } .
 * @ return The user clipping region ( possibly { @ code null } ) .
 * @ see # setClip ( java . awt . Shape ) */
@ Override public Shape getClip ( ) { } }

implementation: if ( this . clip == null ) { return null ; } AffineTransform inv ; try { inv = this . transform . createInverse ( ) ; return inv . createTransformedShape ( this . clip ) ; } catch ( NoninvertibleTransformException ex ) { return null ; }


signature:
public class SVGGraphics2D { /** * Sets the user clipping region .
 * @ param shape the new user clipping region ( { @ code null } permitted ) .
 * @ see # getClip ( ) */
@ Override public void setClip ( Shape shape ) { } }

implementation:
// null is handled fine here . . .
this . clip = this . transform . createTransformedShape ( shape ) ; this . clipRef = null ;


signature:
public class SVGGraphics2D { /** * Registers the clip so that we can later write out all the clip
 * definitions in the DEFS element .
 * @ param clip the clip ( ignored if { @ code null } ) */
private String registerClip ( Shape clip ) { } }

implementation:
if ( clip == null ) { this . clipRef = null ; return null ; } // generate the path
String pathStr = getSVGPathData ( new Path2D . Double ( clip ) ) ; int index = this . clipPaths . indexOf ( pathStr ) ; if ( index < 0 ) { this . clipPaths . add ( pathStr ) ; index = this . clipPaths . size ( ) - 1 ; } return this . defsKeyPrefix + CLIP_KEY_PREFIX + index ;


signature:
public class SVGGraphics2D { /** * Clips to the intersection of the current clipping region and the
 * specified shape .
 * According to the Oracle API specification , this method will accept a
 * { @ code null } argument , but there is an open bug report ( since 2004)
 * that suggests this is wrong :
 * < a href = " http : / / bugs . sun . com / bugdatabase / view _ bug . do ? bug _ id = 6206189 " >
 * http : / / bugs . sun . com / bugdatabase / view _ bug . do ? bug _ id = 6206189 < / a >
 * @ param s the clip shape ( { @ code null } not permitted ) . */
@ Override public void clip ( Shape s ) { } }

implementation: if ( s instanceof Line2D ) { s = s . getBounds2D ( ) ; } if ( this . clip == null ) { setClip ( s ) ; return ; } Shape ts = this . transform . createTransformedShape ( s ) ; if ( ! ts . intersects ( this . clip . getBounds2D ( ) ) ) { setClip ( new Rectangle2D . Double ( ) ) ; } else { Area a1 = new Area ( ts ) ; Area a2 = new Area ( this . clip ) ; a1 . intersect ( a2 ) ; this . clip = new Path2D . Double ( a1 ) ; } this . clipRef = null ;


signature:
public class SVGGraphics2D { /** * Clips to the intersection of the current clipping region and the
 * specified rectangle .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height . */
@ Override public void clipRect ( int x , int y , int width , int height ) { } }

implementation: setRect ( x , y , width , height ) ; clip ( this . rect ) ;


signature:
public class SVGGraphics2D { /** * Sets the user clipping region to the specified rectangle .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ see # getClip ( ) */
@ Override public void setClip ( int x , int y , int width , int height ) { } }

implementation: setRect ( x , y , width , height ) ; setClip ( this . rect ) ;


signature:
public class SVGGraphics2D { /** * Draws a line from { @ code ( x1 , y1 ) } to { @ code ( x2 , y2 ) } using
 * the current { @ code paint } and { @ code stroke } .
 * @ param x1 the x - coordinate of the start point .
 * @ param y1 the y - coordinate of the start point .
 * @ param x2 the x - coordinate of the end point .
 * @ param y2 the x - coordinate of the end point . */
@ Override public void drawLine ( int x1 , int y1 , int x2 , int y2 ) { } }

implementation: if ( this . line == null ) { this . line = new Line2D . Double ( x1 , y1 , x2 , y2 ) ; } else { this . line . setLine ( x1 , y1 , x2 , y2 ) ; } draw ( this . line ) ;


signature:
public class SVGGraphics2D { /** * Fills the specified rectangle with the current { @ code paint } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the rectangle width .
 * @ param height the rectangle height . */
@ Override public void fillRect ( int x , int y , int width , int height ) { } }

implementation: setRect ( x , y , width , height ) ; fill ( this . rect ) ;


signature:
public class SVGGraphics2D { /** * Clears the specified rectangle by filling it with the current
 * background color . If the background color is { @ code null } , this
 * method will do nothing .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ see # getBackground ( ) */
@ Override public void clearRect ( int x , int y , int width , int height ) { } }

implementation:
if ( getBackground ( ) == null ) { return ; // we can ' t do anything
} Paint saved = getPaint ( ) ; setPaint ( getBackground ( ) ) ; fillRect ( x , y , width , height ) ; setPaint ( saved ) ;


signature:
public class SVGGraphics2D { /** * Draws a rectangle with rounded corners using the current
 * { @ code paint } and { @ code stroke } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ param arcWidth the arc - width .
 * @ param arcHeight the arc - height .
 * @ see # fillRoundRect ( int , int , int , int , int , int ) */
@ Override public void drawRoundRect ( int x , int y , int width , int height , int arcWidth , int arcHeight ) { } }

implementation: setRoundRect ( x , y , width , height , arcWidth , arcHeight ) ; draw ( this . roundRect ) ;


signature:
public class SVGGraphics2D { /** * Fills a rectangle with rounded corners using the current { @ code paint } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ param arcWidth the arc - width .
 * @ param arcHeight the arc - height .
 * @ see # drawRoundRect ( int , int , int , int , int , int ) */
@ Override public void fillRoundRect ( int x , int y , int width , int height , int arcWidth , int arcHeight ) { } }

implementation: setRoundRect ( x , y , width , height , arcWidth , arcHeight ) ; fill ( this . roundRect ) ;


signature:
public class SVGGraphics2D { /** * Draws an oval framed by the rectangle { @ code ( x , y , width , height ) }
 * using the current { @ code paint } and { @ code stroke } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ see # fillOval ( int , int , int , int ) */
@ Override public void drawOval ( int x , int y , int width , int height ) { } }

implementation: setOval ( x , y , width , height ) ; draw ( this . oval ) ;


signature:
public class SVGGraphics2D { /** * Fills an oval framed by the rectangle { @ code ( x , y , width , height ) } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ see # drawOval ( int , int , int , int ) */
@ Override public void fillOval ( int x , int y , int width , int height ) { } }

implementation: setOval ( x , y , width , height ) ; fill ( this . oval ) ;


signature:
public class SVGGraphics2D { /** * Draws an arc contained within the rectangle
 * { @ code ( x , y , width , height ) } , starting at { @ code startAngle }
 * and continuing through { @ code arcAngle } degrees using
 * the current { @ code paint } and { @ code stroke } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ param startAngle the start angle in degrees , 0 = 3 o ' clock .
 * @ param arcAngle the angle ( anticlockwise ) in degrees .
 * @ see # fillArc ( int , int , int , int , int , int ) */
@ Override public void drawArc ( int x , int y , int width , int height , int startAngle , int arcAngle ) { } }

implementation: setArc ( x , y , width , height , startAngle , arcAngle ) ; draw ( this . arc ) ;


signature:
public class SVGGraphics2D { /** * Fills an arc contained within the rectangle
 * { @ code ( x , y , width , height ) } , starting at { @ code startAngle }
 * and continuing through { @ code arcAngle } degrees , using
 * the current { @ code paint } .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ param startAngle the start angle in degrees , 0 = 3 o ' clock .
 * @ param arcAngle the angle ( anticlockwise ) in degrees .
 * @ see # drawArc ( int , int , int , int , int , int ) */
@ Override public void fillArc ( int x , int y , int width , int height , int startAngle , int arcAngle ) { } }

implementation: setArc ( x , y , width , height , startAngle , arcAngle ) ; fill ( this . arc ) ;


signature:
public class SVGGraphics2D { /** * Draws the specified multi - segment line using the current
 * { @ code paint } and { @ code stroke } .
 * @ param xPoints the x - points .
 * @ param yPoints the y - points .
 * @ param nPoints the number of points to use for the polyline . */
@ Override public void drawPolyline ( int [ ] xPoints , int [ ] yPoints , int nPoints ) { } }

implementation: GeneralPath p = GraphicsUtils . createPolygon ( xPoints , yPoints , nPoints , false ) ; draw ( p ) ;


signature:
public class SVGGraphics2D { /** * Draws the specified polygon using the current { @ code paint } and
 * { @ code stroke } .
 * @ param xPoints the x - points .
 * @ param yPoints the y - points .
 * @ param nPoints the number of points to use for the polygon .
 * @ see # fillPolygon ( int [ ] , int [ ] , int ) */
@ Override public void drawPolygon ( int [ ] xPoints , int [ ] yPoints , int nPoints ) { } }

implementation: GeneralPath p = GraphicsUtils . createPolygon ( xPoints , yPoints , nPoints , true ) ; draw ( p ) ;


signature:
public class SVGGraphics2D { /** * Fills the specified polygon using the current { @ code paint } .
 * @ param xPoints the x - points .
 * @ param yPoints the y - points .
 * @ param nPoints the number of points to use for the polygon .
 * @ see # drawPolygon ( int [ ] , int [ ] , int ) */
@ Override public void fillPolygon ( int [ ] xPoints , int [ ] yPoints , int nPoints ) { } }

implementation: GeneralPath p = GraphicsUtils . createPolygon ( xPoints , yPoints , nPoints , true ) ; fill ( p ) ;


signature:
public class SVGGraphics2D { /** * Returns the bytes representing a PNG format image .
 * @ param img the image to encode .
 * @ return The bytes representing a PNG format image . */
private byte [ ] getPNGBytes ( Image img ) { } }

implementation: RenderedImage ri ; if ( img instanceof RenderedImage ) { ri = ( RenderedImage ) img ; } else { BufferedImage bi = new BufferedImage ( img . getWidth ( null ) , img . getHeight ( null ) , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g2 = bi . createGraphics ( ) ; g2 . drawImage ( img , 0 , 0 , null ) ; ri = bi ; } ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { ImageIO . write ( ri , "png" , baos ) ; } catch ( IOException ex ) { Logger . getLogger ( SVGGraphics2D . class . getName ( ) ) . log ( Level . SEVERE , "IOException while writing PNG data." , ex ) ; } return baos . toByteArray ( ) ;


signature:
public class SVGGraphics2D { /** * Draws the image into the rectangle defined by { @ code ( x , y , w , h ) } .
 * Note that the { @ code observer } is ignored ( it is not useful in this
 * context ) .
 * @ param img the image ( { @ code null } permitted . . . draws nothing ) .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param w the width .
 * @ param h the height .
 * @ param observer ignored .
 * @ return { @ code true } if there is no more drawing to be done . */
@ Override public boolean drawImage ( Image img , int x , int y , int w , int h , ImageObserver observer ) { } }

implementation:
if ( img == null ) { return true ; } // the rendering hints control whether the image is embedded or
// referenced . . .
Object hint = getRenderingHint ( SVGHints . KEY_IMAGE_HANDLING ) ; if ( SVGHints . VALUE_IMAGE_HANDLING_EMBED . equals ( hint ) ) { this . sb . append ( "<image " ) ; appendOptionalElementIDFromHint ( this . sb ) ; this . sb . append ( "preserveAspectRatio=\"none\" " ) ; this . sb . append ( "xlink:href=\"data:image/png;base64," ) ; this . sb . append ( Base64 . getEncoder ( ) . encode ( getPNGBytes ( img ) ) ) ; this . sb . append ( "\" " ) ; this . sb . append ( getClipPathRef ( ) ) . append ( " " ) ; if ( ! this . transform . isIdentity ( ) ) { this . sb . append ( "transform=\"" ) . append ( getSVGTransform ( this . transform ) ) . append ( "\" " ) ; } this . sb . append ( "x=\"" ) . append ( geomDP ( x ) ) . append ( "\" y=\"" ) . append ( geomDP ( y ) ) . append ( "\" " ) ; this . sb . append ( "width=\"" ) . append ( geomDP ( w ) ) . append ( "\" height=\"" ) . append ( geomDP ( h ) ) . append ( "\"/>\n" ) ; return true ; } else { // here for SVGHints . VALUE _ IMAGE _ HANDLING _ REFERENCE
int count = this . imageElements . size ( ) ; String href = ( String ) this . hints . get ( SVGHints . KEY_IMAGE_HREF ) ; if ( href == null ) { href = this . filePrefix + count + this . fileSuffix ; } else { // KEY _ IMAGE _ HREF value is for a single use . . .
this . hints . put ( SVGHints . KEY_IMAGE_HREF , null ) ; } ImageElement imageElement = new ImageElement ( href , img ) ; this . imageElements . add ( imageElement ) ; // write an SVG element for the img
this . sb . append ( "<image " ) ; appendOptionalElementIDFromHint ( this . sb ) ; this . sb . append ( "xlink:href=\"" ) ; this . sb . append ( href ) . append ( "\" " ) ; this . sb . append ( getClipPathRef ( ) ) . append ( " " ) ; if ( ! this . transform . isIdentity ( ) ) { this . sb . append ( "transform=\"" ) . append ( getSVGTransform ( this . transform ) ) . append ( "\" " ) ; } this . sb . append ( "x=\"" ) . append ( geomDP ( x ) ) . append ( "\" y=\"" ) . append ( geomDP ( y ) ) . append ( "\" " ) ; this . sb . append ( "width=\"" ) . append ( geomDP ( w ) ) . append ( "\" height=\"" ) . append ( geomDP ( h ) ) . append ( "\"/>\n" ) ; return true ; }


signature:
public class SVGGraphics2D { /** * Draws an image at the location { @ code ( x , y ) } . Note that the
 * { @ code observer } is ignored .
 * @ param img the image ( { @ code null } permitted . . . draws nothing ) .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param bgcolor the background color ( { @ code null } permitted ) .
 * @ param observer ignored .
 * @ return { @ code true } if there is no more drawing to be done . */
@ Override public boolean drawImage ( Image img , int x , int y , Color bgcolor , ImageObserver observer ) { } }

implementation: if ( img == null ) { return true ; } int w = img . getWidth ( null ) ; if ( w < 0 ) { return false ; } int h = img . getHeight ( null ) ; if ( h < 0 ) { return false ; } return drawImage ( img , x , y , w , h , bgcolor , observer ) ;


signature:
public class SVGGraphics2D { /** * Draws an image to the rectangle { @ code ( x , y , w , h ) } ( scaling it if
 * required ) , first filling the background with the specified color . Note
 * that the { @ code observer } is ignored .
 * @ param img the image .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param w the width .
 * @ param h the height .
 * @ param bgcolor the background color ( { @ code null } permitted ) .
 * @ param observer ignored .
 * @ return { @ code true } if the image is drawn . */
@ Override public boolean drawImage ( Image img , int x , int y , int w , int h , Color bgcolor , ImageObserver observer ) { } }

implementation: Paint saved = getPaint ( ) ; setPaint ( bgcolor ) ; fillRect ( x , y , w , h ) ; setPaint ( saved ) ; return drawImage ( img , x , y , w , h , observer ) ;


signature:
public class SVGGraphics2D { /** * Draws part of an image ( defined by the source rectangle
 * { @ code ( sx1 , sy1 , sx2 , sy2 ) } ) into the destination rectangle
 * { @ code ( dx1 , dy1 , dx2 , dy2 ) } . Note that the { @ code observer } is ignored .
 * @ param img the image .
 * @ param dx1 the x - coordinate for the top left of the destination .
 * @ param dy1 the y - coordinate for the top left of the destination .
 * @ param dx2 the x - coordinate for the bottom right of the destination .
 * @ param dy2 the y - coordinate for the bottom right of the destination .
 * @ param sx1 the x - coordinate for the top left of the source .
 * @ param sy1 the y - coordinate for the top left of the source .
 * @ param sx2 the x - coordinate for the bottom right of the source .
 * @ param sy2 the y - coordinate for the bottom right of the source .
 * @ return { @ code true } if the image is drawn . */
@ Override public boolean drawImage ( Image img , int dx1 , int dy1 , int dx2 , int dy2 , int sx1 , int sy1 , int sx2 , int sy2 , ImageObserver observer ) { } }

implementation: int w = dx2 - dx1 ; int h = dy2 - dy1 ; BufferedImage img2 = new BufferedImage ( w , h , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g2 = img2 . createGraphics ( ) ; g2 . drawImage ( img , 0 , 0 , w , h , sx1 , sy1 , sx2 , sy2 , null ) ; return drawImage ( img2 , dx1 , dy1 , null ) ;


signature:
public class SVGGraphics2D { /** * Draws part of an image ( defined by the source rectangle
 * { @ code ( sx1 , sy1 , sx2 , sy2 ) } ) into the destination rectangle
 * { @ code ( dx1 , dy1 , dx2 , dy2 ) } . The destination rectangle is first
 * cleared by filling it with the specified { @ code bgcolor } . Note that
 * the { @ code observer } is ignored .
 * @ param img the image .
 * @ param dx1 the x - coordinate for the top left of the destination .
 * @ param dy1 the y - coordinate for the top left of the destination .
 * @ param dx2 the x - coordinate for the bottom right of the destination .
 * @ param dy2 the y - coordinate for the bottom right of the destination .
 * @ param sx1 the x - coordinate for the top left of the source .
 * @ param sy1 the y - coordinate for the top left of the source .
 * @ param sx2 the x - coordinate for the bottom right of the source .
 * @ param sy2 the y - coordinate for the bottom right of the source .
 * @ param bgcolor the background color ( { @ code null } permitted ) .
 * @ param observer ignored .
 * @ return { @ code true } if the image is drawn . */
@ Override public boolean drawImage ( Image img , int dx1 , int dy1 , int dx2 , int dy2 , int sx1 , int sy1 , int sx2 , int sy2 , Color bgcolor , ImageObserver observer ) { } }

implementation: Paint saved = getPaint ( ) ; setPaint ( bgcolor ) ; fillRect ( dx1 , dy1 , dx2 - dx1 , dy2 - dy1 ) ; setPaint ( saved ) ; return drawImage ( img , dx1 , dy1 , dx2 , dy2 , sx1 , sy1 , sx2 , sy2 , observer ) ;


signature:
public class SVGGraphics2D { /** * Draws the rendered image .
 * @ param img the image .
 * @ param xform the transform . */
@ Override public void drawRenderedImage ( RenderedImage img , AffineTransform xform ) { } }

implementation: BufferedImage bi = GraphicsUtils . convertRenderedImage ( img ) ; drawImage ( bi , xform , null ) ;


signature:
public class SVGGraphics2D { /** * Draws the renderable image .
 * @ param img the renderable image .
 * @ param xform the transform . */
@ Override public void drawRenderableImage ( RenderableImage img , AffineTransform xform ) { } }

implementation: RenderedImage ri = img . createDefaultRendering ( ) ; drawRenderedImage ( ri , xform ) ;


signature:
public class SVGGraphics2D { /** * Draws an image with the specified transform . Note that the
 * { @ code observer } is ignored .
 * @ param img the image .
 * @ param xform the transform ( { @ code null } permitted ) .
 * @ param obs the image observer ( ignored ) .
 * @ return { @ code true } if the image is drawn . */
@ Override public boolean drawImage ( Image img , AffineTransform xform , ImageObserver obs ) { } }

implementation: AffineTransform savedTransform = getTransform ( ) ; if ( xform != null ) { transform ( xform ) ; } boolean result = drawImage ( img , 0 , 0 , obs ) ; if ( xform != null ) { setTransform ( savedTransform ) ; } return result ;


signature:
public class SVGGraphics2D { /** * Draws the image resulting from applying the { @ code BufferedImageOp }
 * to the specified image at the location { @ code ( x , y ) } .
 * @ param img the image .
 * @ param op the operation ( { @ code null } permitted ) .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate . */
@ Override public void drawImage ( BufferedImage img , BufferedImageOp op , int x , int y ) { } }

implementation: BufferedImage imageToDraw = img ; if ( op != null ) { imageToDraw = op . filter ( img , null ) ; } drawImage ( imageToDraw , new AffineTransform ( 1f , 0f , 0f , 1f , x , y ) , null ) ;


signature:
public class SVGGraphics2D { /** * Returns the SVG element that has been generated by calls to this
 * { @ code Graphics2D } implementation , giving it the specified { @ code id } .
 * If { @ code id } is { @ code null } , the element will have no { @ code id }
 * attribute .
 * @ param id the element id ( { @ code null } permitted ) .
 * @ return A string containing the SVG element .
 * @ since 1.8 */
public String getSVGElement ( String id ) { } }

implementation: return getSVGElement ( id , true , null , null , null ) ;


signature:
public class SVGGraphics2D { /** * Returns the SVG element that has been generated by calls to this
 * { @ code Graphics2D } implementation , giving it the specified { @ code id } .
 * If { @ code id } is { @ code null } , the element will have no { @ code id }
 * attribute . This method also allows for a { @ code viewBox } to be defined ,
 * along with the settings that handle scaling .
 * @ param id the element id ( { @ code null } permitted ) .
 * @ param includeDimensions include the width and height attributes ?
 * @ param viewBox the view box specification ( if { @ code null } then no
 * { @ code viewBox } attribute will be defined ) .
 * @ param preserveAspectRatio the value of the { @ code preserveAspectRatio }
 * attribute ( if { @ code null } then not attribute will be defined ) .
 * @ param meetOrSlice the value of the meetOrSlice attribute .
 * @ return A string containing the SVG element .
 * @ since 3.2 */
public String getSVGElement ( String id , boolean includeDimensions , ViewBox viewBox , PreserveAspectRatio preserveAspectRatio , MeetOrSlice meetOrSlice ) { } }

implementation: StringBuilder svg = new StringBuilder ( "<svg " ) ; if ( id != null ) { svg . append ( "id=\"" ) . append ( id ) . append ( "\" " ) ; } String unitStr = this . units != null ? this . units . toString ( ) : "" ; svg . append ( "xmlns=\"http://www.w3.org/2000/svg\" " ) . append ( "xmlns:xlink=\"http://www.w3.org/1999/xlink\" " ) . append ( "xmlns:jfreesvg=\"http://www.jfree.org/jfreesvg/svg\" " ) ; if ( includeDimensions ) { svg . append ( "width=\"" ) . append ( this . width ) . append ( unitStr ) . append ( "\" height=\"" ) . append ( this . height ) . append ( unitStr ) . append ( "\" " ) ; } if ( viewBox != null ) { svg . append ( "viewBox=\"" ) . append ( viewBox . valueStr ( ) ) . append ( "\" " ) ; if ( preserveAspectRatio != null ) { svg . append ( "preserveAspectRatio=\"" ) . append ( preserveAspectRatio . toString ( ) ) ; if ( meetOrSlice != null ) { svg . append ( " " ) . append ( meetOrSlice . toString ( ) ) ; } svg . append ( "\" " ) ; } } svg . append ( "text-rendering=\"" ) . append ( this . textRendering ) . append ( "\" shape-rendering=\"" ) . append ( this . shapeRendering ) . append ( "\">\n" ) ; StringBuilder defs = new StringBuilder ( "<defs>" ) ; for ( GradientPaintKey key : this . gradientPaints . keySet ( ) ) { defs . append ( getLinearGradientElement ( this . gradientPaints . get ( key ) , key . getPaint ( ) ) ) ; defs . append ( "\n" ) ; } for ( LinearGradientPaintKey key : this . linearGradientPaints . keySet ( ) ) { defs . append ( getLinearGradientElement ( this . linearGradientPaints . get ( key ) , key . getPaint ( ) ) ) ; defs . append ( "\n" ) ; } for ( RadialGradientPaintKey key : this . radialGradientPaints . keySet ( ) ) { defs . append ( getRadialGradientElement ( this . radialGradientPaints . get ( key ) , key . getPaint ( ) ) ) ; defs . append ( "\n" ) ; } for ( int i = 0 ; i < this . clipPaths . size ( ) ; i ++ ) { StringBuilder b = new StringBuilder ( "<clipPath id=\"" ) . append ( this . defsKeyPrefix ) . append ( CLIP_KEY_PREFIX ) . append ( i ) . append ( "\">" ) ; b . append ( "<path " ) . append ( this . clipPaths . get ( i ) ) . append ( "/>" ) ; b . append ( "</clipPath>" ) . append ( "\n" ) ; defs . append ( b . toString ( ) ) ; } defs . append ( "</defs>\n" ) ; svg . append ( defs ) ; svg . append ( this . sb ) ; svg . append ( "</svg>" ) ; return svg . toString ( ) ;


signature:
public class SVGGraphics2D { /** * Returns an SVG document ( this contains the content returned by the
 * { @ link # getSVGElement ( ) } method , prepended with the required document
 * header ) .
 * @ return An SVG document . */
public String getSVGDocument ( ) { } }

implementation: StringBuilder b = new StringBuilder ( ) ; b . append ( "<?xml version=\"1.0\"?>\n" ) ; b . append ( "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" " ) ; b . append ( "\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n" ) ; b . append ( getSVGElement ( ) ) ; return b . append ( "\n" ) . toString ( ) ;


signature:
public class SVGGraphics2D { /** * Returns an element to represent a linear gradient . All the linear
 * gradients that are used get written to the DEFS element in the SVG .
 * @ param id the reference id .
 * @ param paint the gradient .
 * @ return The SVG element . */
private String getLinearGradientElement ( String id , GradientPaint paint ) { } }

implementation: StringBuilder b = new StringBuilder ( "<linearGradient id=\"" ) . append ( id ) . append ( "\" " ) ; Point2D p1 = paint . getPoint1 ( ) ; Point2D p2 = paint . getPoint2 ( ) ; b . append ( "x1=\"" ) . append ( geomDP ( p1 . getX ( ) ) ) . append ( "\" " ) ; b . append ( "y1=\"" ) . append ( geomDP ( p1 . getY ( ) ) ) . append ( "\" " ) ; b . append ( "x2=\"" ) . append ( geomDP ( p2 . getX ( ) ) ) . append ( "\" " ) ; b . append ( "y2=\"" ) . append ( geomDP ( p2 . getY ( ) ) ) . append ( "\" " ) ; b . append ( "gradientUnits=\"userSpaceOnUse\">" ) ; Color c1 = paint . getColor1 ( ) ; b . append ( "<stop offset=\"0%\" stop-color=\"" ) . append ( rgbColorStr ( c1 ) ) . append ( "\"" ) ; if ( c1 . getAlpha ( ) < 255 ) { double alphaPercent = c1 . getAlpha ( ) / 255.0 ; b . append ( " stop-opacity=\"" ) . append ( transformDP ( alphaPercent ) ) . append ( "\"" ) ; } b . append ( "/>" ) ; Color c2 = paint . getColor2 ( ) ; b . append ( "<stop offset=\"100%\" stop-color=\"" ) . append ( rgbColorStr ( c2 ) ) . append ( "\"" ) ; if ( c2 . getAlpha ( ) < 255 ) { double alphaPercent = c2 . getAlpha ( ) / 255.0 ; b . append ( " stop-opacity=\"" ) . append ( transformDP ( alphaPercent ) ) . append ( "\"" ) ; } b . append ( "/>" ) ; return b . append ( "</linearGradient>" ) . toString ( ) ;


signature:
public class SVGGraphics2D { /** * Returns an element to represent a linear gradient . All the linear
 * gradients that are used get written to the DEFS element in the SVG .
 * @ param id the reference id .
 * @ param paint the gradient .
 * @ return The SVG element . */
private String getLinearGradientElement ( String id , LinearGradientPaint paint ) { } }

implementation: StringBuilder b = new StringBuilder ( "<linearGradient id=\"" ) . append ( id ) . append ( "\" " ) ; Point2D p1 = paint . getStartPoint ( ) ; Point2D p2 = paint . getEndPoint ( ) ; b . append ( "x1=\"" ) . append ( geomDP ( p1 . getX ( ) ) ) . append ( "\" " ) ; b . append ( "y1=\"" ) . append ( geomDP ( p1 . getY ( ) ) ) . append ( "\" " ) ; b . append ( "x2=\"" ) . append ( geomDP ( p2 . getX ( ) ) ) . append ( "\" " ) ; b . append ( "y2=\"" ) . append ( geomDP ( p2 . getY ( ) ) ) . append ( "\" " ) ; if ( ! paint . getCycleMethod ( ) . equals ( CycleMethod . NO_CYCLE ) ) { String sm = paint . getCycleMethod ( ) . equals ( CycleMethod . REFLECT ) ? "reflect" : "repeat" ; b . append ( "spreadMethod=\"" ) . append ( sm ) . append ( "\" " ) ; } b . append ( "gradientUnits=\"userSpaceOnUse\">" ) ; for ( int i = 0 ; i < paint . getFractions ( ) . length ; i ++ ) { Color c = paint . getColors ( ) [ i ] ; float fraction = paint . getFractions ( ) [ i ] ; b . append ( "<stop offset=\"" ) . append ( geomDP ( fraction * 100 ) ) . append ( "%\" stop-color=\"" ) . append ( rgbColorStr ( c ) ) . append ( "\"" ) ; if ( c . getAlpha ( ) < 255 ) { double alphaPercent = c . getAlpha ( ) / 255.0 ; b . append ( " stop-opacity=\"" ) . append ( transformDP ( alphaPercent ) ) . append ( "\"" ) ; } b . append ( "/>" ) ; } return b . append ( "</linearGradient>" ) . toString ( ) ;


signature:
public class SVGGraphics2D { /** * Returns an element to represent a radial gradient . All the radial
 * gradients that are used get written to the DEFS element in the SVG .
 * @ param id the reference id .
 * @ param rgp the radial gradient .
 * @ return The SVG element . */
private String getRadialGradientElement ( String id , RadialGradientPaint rgp ) { } }

implementation: StringBuilder b = new StringBuilder ( "<radialGradient id=\"" ) . append ( id ) . append ( "\" gradientUnits=\"userSpaceOnUse\" " ) ; Point2D center = rgp . getCenterPoint ( ) ; Point2D focus = rgp . getFocusPoint ( ) ; float radius = rgp . getRadius ( ) ; b . append ( "cx=\"" ) . append ( geomDP ( center . getX ( ) ) ) . append ( "\" " ) ; b . append ( "cy=\"" ) . append ( geomDP ( center . getY ( ) ) ) . append ( "\" " ) ; b . append ( "r=\"" ) . append ( geomDP ( radius ) ) . append ( "\" " ) ; b . append ( "fx=\"" ) . append ( geomDP ( focus . getX ( ) ) ) . append ( "\" " ) ; b . append ( "fy=\"" ) . append ( geomDP ( focus . getY ( ) ) ) . append ( "\">" ) ; Color [ ] colors = rgp . getColors ( ) ; float [ ] fractions = rgp . getFractions ( ) ; for ( int i = 0 ; i < colors . length ; i ++ ) { Color c = colors [ i ] ; float f = fractions [ i ] ; b . append ( "<stop offset=\"" ) . append ( geomDP ( f * 100 ) ) . append ( "%\" " ) ; b . append ( "stop-color=\"" ) . append ( rgbColorStr ( c ) ) . append ( "\"" ) ; if ( c . getAlpha ( ) < 255 ) { double alphaPercent = c . getAlpha ( ) / 255.0 ; b . append ( " stop-opacity=\"" ) . append ( transformDP ( alphaPercent ) ) . append ( "\"" ) ; } b . append ( "/>" ) ; } return b . append ( "</radialGradient>" ) . toString ( ) ;


signature:
public class SVGGraphics2D { /** * Returns a clip path reference for the current user clip . This is
 * written out on all SVG elements that draw or fill shapes or text .
 * @ return A clip path reference . */
private String getClipPathRef ( ) { } }

implementation: if ( this . clip == null ) { return "" ; } if ( this . clipRef == null ) { this . clipRef = registerClip ( getClip ( ) ) ; } StringBuilder b = new StringBuilder ( ) ; b . append ( "clip-path=\"url(#" ) . append ( this . clipRef ) . append ( ")\"" ) ; return b . toString ( ) ;


signature:
public class SVGGraphics2D { /** * Sets the attributes of the reusable { @ link Rectangle2D } object that is
 * used by the { @ link SVGGraphics2D # drawRect ( int , int , int , int ) } and
 * { @ link SVGGraphics2D # fillRect ( int , int , int , int ) } methods .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height . */
private void setRect ( int x , int y , int width , int height ) { } }

implementation: if ( this . rect == null ) { this . rect = new Rectangle2D . Double ( x , y , width , height ) ; } else { this . rect . setRect ( x , y , width , height ) ; }


signature:
public class SVGGraphics2D { /** * Sets the attributes of the reusable { @ link RoundRectangle2D } object that
 * is used by the { @ link # drawRoundRect ( int , int , int , int , int , int ) } and
 * { @ link # fillRoundRect ( int , int , int , int , int , int ) } methods .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ param arcWidth the arc width .
 * @ param arcHeight the arc height . */
private void setRoundRect ( int x , int y , int width , int height , int arcWidth , int arcHeight ) { } }

implementation: if ( this . roundRect == null ) { this . roundRect = new RoundRectangle2D . Double ( x , y , width , height , arcWidth , arcHeight ) ; } else { this . roundRect . setRoundRect ( x , y , width , height , arcWidth , arcHeight ) ; }


signature:
public class SVGGraphics2D { /** * Sets the attributes of the reusable { @ link Arc2D } object that is used by
 * { @ link # drawArc ( int , int , int , int , int , int ) } and
 * { @ link # fillArc ( int , int , int , int , int , int ) } methods .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height .
 * @ param startAngle the start angle in degrees , 0 = 3 o ' clock .
 * @ param arcAngle the angle ( anticlockwise ) in degrees . */
private void setArc ( int x , int y , int width , int height , int startAngle , int arcAngle ) { } }

implementation: if ( this . arc == null ) { this . arc = new Arc2D . Double ( x , y , width , height , startAngle , arcAngle , Arc2D . PIE ) ; } else { this . arc . setArc ( x , y , width , height , startAngle , arcAngle , Arc2D . PIE ) ; }


signature:
public class SVGGraphics2D { /** * Sets the attributes of the reusable { @ link Ellipse2D } object that is
 * used by the { @ link # drawOval ( int , int , int , int ) } and
 * { @ link # fillOval ( int , int , int , int ) } methods .
 * @ param x the x - coordinate .
 * @ param y the y - coordinate .
 * @ param width the width .
 * @ param height the height . */
private void setOval ( int x , int y , int width , int height ) { } }

implementation: if ( this . oval == null ) { this . oval = new Ellipse2D . Double ( x , y , width , height ) ; } else { this . oval . setFrame ( x , y , width , height ) ; }


signature:
public class FindbugsParser { /** * Bugs are given a rank 1-20 , and grouped into the categories scariest ( rank 1-4 ) , scary ( rank
 * 5-9 ) , troubling ( rank 10-14 ) , and of concern ( rank 15-20 ) . */
private SEVERITY toSeverity ( Integer rank ) { } }

implementation: if ( rank <= 9 ) { return SEVERITY . ERROR ; } if ( rank <= 14 ) { return SEVERITY . WARN ; } return SEVERITY . INFO ;


signature:
public class ViolationParserUtils { /** * Match one regexp at a time . Remove the matched part from the string , trim , and match next
 * regexp on that string . . . */
public static List < String > getParts ( String string , final String ... regexpList ) { } }

implementation: final List < String > parts = new ArrayList < > ( ) ; for ( final String regexp : regexpList ) { final Pattern pattern = Pattern . compile ( regexp ) ; final Matcher matcher = pattern . matcher ( string ) ; final boolean found = matcher . find ( ) ; if ( ! found ) { return new ArrayList < > ( ) ; } final String part = matcher . group ( 1 ) . trim ( ) ; parts . add ( part ) ; string = string . replaceFirst ( quote ( matcher . group ( ) ) , "" ) . trim ( ) ; } return parts ;


signature: public class HttpVertxClient { @ Override public void sendHttpRequest ( final HttpRequest request ) { } }

implementation: checkClosed ( ) ; if ( trace ) { logger . debug ( sputs ( "HTTP CLIENT: sendHttpRequest:: \n{}\n" , request , "\nparams\n" , request . params ( ) ) ) ; } final String uri = getURICreateParamsIfNeeded ( request ) ; final HttpMethod httpMethod = HttpMethod . valueOf ( request . getMethod ( ) ) ; final HttpClientRequest httpClientRequest = httpClient . request ( httpMethod , uri , httpClientResponse -> handleResponse ( request , httpClientResponse ) ) ; final MultiMap < String , String > headers = request . getHeaders ( ) ; httpClientRequest . exceptionHandler ( error -> { if ( error instanceof ConnectException ) { closed . set ( true ) ; try { stop ( ) ; } catch ( Exception ex ) { errorHandler . accept ( ex ) ; logger . warn ( "Unable to stop client " + "after failed connection" , ex ) ; } request . getReceiver ( ) . errorWithCode ( "\"Client connection was closed\"" , HttpStatus . SERVICE_UNAVAILABLE ) ; logger . warn ( "Connection error" , error ) ; } else { logger . error ( "Unable to connect to " + host + " port " + port , error ) ; } errorHandler . accept ( error ) ; } ) ; if ( headers != null ) { for ( String key : headers . keySet ( ) ) { httpClientRequest . putHeader ( key , headers . getAll ( key ) ) ; } } final byte [ ] body = request . getBody ( ) ; if ( keepAlive ) { httpClientRequest . putHeader ( HttpHeaders . CONNECTION , HttpHeaders . KEEP_ALIVE ) ; } if ( body != null && body . length > 0 ) { httpClientRequest . putHeader ( HttpHeaders . CONTENT_LENGTH , Integer . toString ( body . length ) ) ; if ( request . getContentType ( ) != null ) { httpClientRequest . putHeader ( "Content-Type" , request . getContentType ( ) ) ; } httpClientRequest . end ( Buffer . buffer ( request . getBody ( ) ) ) ; } else { httpClientRequest . end ( ) ; } if ( trace ) logger . trace ( "HttpClientVertx::SENT \n{}" , request ) ;


signature:
public class BaseService { /** * Prefixes the stats key with the stat key prefix , and then calls statsCollector . recordLevel .
 * @ param statKey statKey
 * @ param level level */
protected void recordLevel ( final String statKey , final long level ) { } }

implementation: final String longKey = getActualStatKey ( statKey ) ; statsCollector . recordLevel ( longKey , level ) ;


signature:
public class BaseService { /** * Prefixes the stats key with the stat key prefix , and then calls statsCollector . recordCount .
 * @ param statKey statKey
 * @ param count count */
protected void recordCount ( final String statKey , final long count ) { } }

implementation: final String longKey = getActualStatKey ( statKey ) ; statsCollector . recordCount ( longKey , count ) ;


signature:
public class BaseService { /** * Prefixes the stats key with the stat key prefix , and then calls statsCollector . recordCount .
 * @ param statKey statKey */
protected void incrementCount ( final String statKey ) { } }

implementation: final String longKey = getActualStatKey ( statKey ) ; statsCollector . recordCount ( longKey , 1 ) ;


signature:
public class BaseService { /** * Prefixes the stats key with the stat key prefix , and then calls statsCollector . recordTiming .
 * @ param statKey statKey
 * @ param timeSpan timeSpan */
protected void recordTiming ( String statKey , long timeSpan ) { } }

implementation: final String longKey = getActualStatKey ( statKey ) ; statsCollector . recordTiming ( longKey , timeSpan ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a node .
 * GET / v1 / health / node / { node }
 * @ param node node
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getNodeChecks ( String node ) { } }

implementation: return getNodeChecks ( node , null , null , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a node in a given datacenter .
 * < code > GET / v1 / health / node / { node } ? dc = { datacenter } < / code >
 * @ param node node
 * @ param datacenter datacenter
 * @ param tag tag
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getNodeChecks ( String node , final String datacenter , final String tag ) { } }

implementation: return getNodeChecks ( node , datacenter , tag , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a node in a given datacenter with { @ link io . advantageous . consul . domain . option . RequestOptions } .
 * GET / v1 / health / node / { node } ? dc = { datacenter }
 * @ param node node
 * @ param datacenter datacenter
 * @ param tag tag
 * @ param requestOptions The Query Options to use .
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getNodeChecks ( final String node , final String datacenter , final String tag , final RequestOptions requestOptions ) { } }

implementation: final URI uri = createURI ( "/node/" + node ) ; final HttpRequestBuilder httpRequestBuilder = RequestUtils . getHttpRequestBuilder ( datacenter , tag , requestOptions , "" ) ; final HTTP . Response httpResponse = HTTP . getResponse ( uri . toString ( ) + "?" + httpRequestBuilder . paramString ( ) ) ; if ( httpResponse == null || httpResponse . code ( ) != 200 ) { die ( "Unable to retrieve the service" , uri , httpResponse ) ; } return RequestUtils . consulResponseList ( HealthCheck . class , httpResponse ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a service .
 * GET / v1 / health / service / { service }
 * @ param service service
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getServiceChecks ( final String service ) { } }

implementation: return getNodeChecks ( service , null , null , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a service in a given datacenter .
 * GET / v1 / health / service / { service } ? dc = { datacenter }
 * @ param service service
 * @ param datacenter datacenter
 * @ param tag tag
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getServiceChecks ( String service , final String datacenter , final String tag ) { } }

implementation: return getNodeChecks ( service , datacenter , tag , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a state .
 * GET / v1 / health / state / { state }
 * @ param status The state to query .
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getChecksByState ( Status status ) { } }

implementation: return getChecksByState ( status , null , null , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for a state in a given datacenter .
 * GET / v1 / health / state / { state } ? dc = { datacenter }
 * @ param status The state to query .
 * @ param datacenter datacenter
 * @ param tag tag
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < HealthCheck > > getChecksByState ( final Status status , final String datacenter , final String tag ) { } }

implementation: return getChecksByState ( status , datacenter , tag , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for all healthy nodes .
 * GET / v1 / health / service / { service } ? passing
 * @ param serviceName The service to query .
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < ServiceHealth > > getHealthyServices ( final String serviceName ) { } }

implementation: return getHealthyServices ( serviceName , null , null , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for all healthy nodes in a given datacenter .
 * < code > GET / v1 / health / service / { service } ? dc = { datacenter } & amp ; passing < / code >
 * @ param serviceName The service to query .
 * @ param datacenter datacenter
 * @ param tag tag
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < ServiceHealth > > getHealthyServicesByDatacenterAndTag ( final String serviceName , final String datacenter , final String tag ) { } }

implementation: return getHealthyServices ( serviceName , datacenter , tag , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for all healthy nodes with { @ link io . advantageous . consul . domain . option . RequestOptions } .
 * < code > GET / v1 / health / service / { service } ? passing < / code >
 * @ param serviceName The service to query .
 * @ param requestOptions The Query Options to use .
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < ServiceHealth > > getHealthyServicesWithRequestOptions ( String serviceName , RequestOptions requestOptions ) { } }

implementation: return getHealthyServices ( serviceName , null , null , requestOptions ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for all nodes .
 * GET / v1 / health / service / { service }
 * @ param service The service to query .
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < ServiceHealth > > getAllNodes ( String service ) { } }

implementation: return getAllNodes ( service , null , null , RequestOptions . BLANK ) ;


signature:
public class HealthEndpoint { /** * Retrieves the healthchecks for all nodes in a given datacenter .
 * GET / v1 / health / service / { service } ? dc = { datacenter }
 * @ param service The service to query .
 * @ param datacenter datacenter
 * @ param tag tag
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a list of
 * { @ link io . advantageous . consul . domain . HealthCheck } objects . */
public ConsulResponse < List < ServiceHealth > > getAllNodes ( String service , final String datacenter , final String tag ) { } }

implementation: return getAllNodes ( service , datacenter , tag , RequestOptions . BLANK ) ;


signature:
public class RequestContext { /** * Grab the current request .
 * @ return Optional request . */
public Optional < Request < Object > > getRequest ( ) { } }

implementation: final Request request = requestThreadLocal . get ( ) ; return Optional . ofNullable ( request ) ;


signature:
public class RequestContext { /** * Grab the current request .
 * @ return Optional request . */
public Optional < MethodCall < Object > > getMethodCall ( ) { } }

implementation: final Request < Object > request = requestThreadLocal . get ( ) ; if ( request instanceof MethodCall ) { return Optional . of ( ( ( MethodCall < Object > ) request ) ) ; } return Optional . empty ( ) ;


signature:
public class ProxyServiceImpl { /** * Tracks timeouts periodically if timeout tracking is enabled . */
private void trackTimeouts ( ) { } }

implementation:
new ArrayList < > ( httpRequestHolderList ) . forEach ( httpRequestHolder -> { /* If it is handled then remove it from the list . */
if ( httpRequestHolder . request . isHandled ( ) ) { httpRequestHolderList . remove ( httpRequestHolder ) ; return ; } /* Get the duration that this request has been around . */
final long duration = time - httpRequestHolder . startTime ; /* See if the duration is greater than the timeout time . */
if ( duration > timeOutIntervalMS ) { /* If we timed out , mark the request as handled , and then notify the client that the
 backend timed out . */
httpRequestHolder . request . handled ( ) ; /* Tell client that the backend timed out . */
httpRequestHolder . request . getReceiver ( ) . timeoutWithMessage ( String . format ( "\"TIMEOUT %s %s %s\"" , httpRequestHolder . request . address ( ) , httpRequestHolder . request . getRemoteAddress ( ) , httpRequestHolder . startTime ) ) ; /* If we timed out then remove this from the list . */
httpRequestHolderList . remove ( httpRequestHolder ) ; // Not very fast if you a lot of outstanding requests
} } ) ;


signature:
public class ProxyServiceImpl { /** * Request coming from the client side .
 * @ param clientRequest clientRequest */
@ Override public void handleRequest ( final HttpRequest clientRequest ) { } }

implementation: if ( trackTimeOuts ) { httpRequestHolderList . add ( new HttpRequestHolder ( clientRequest , time ) ) ; } if ( httpClientRequestPredicate . test ( clientRequest ) ) { createBackEndRequestPopulateAndForward ( clientRequest ) ; }


signature:
public class ProxyServiceImpl { /** * Handle errors .
 * @ param clientRequest clientRequest
 * @ param e exception */
private void handleHttpClientErrorsForBackend ( final HttpRequest clientRequest , final Exception e ) { } }

implementation:
/* Notify error handler that we got an error . */
errorHandler . accept ( e ) ; /* Increment our error count . */
errorCount . incrementAndGet ( ) ; /* Create the error message . */
final String errorMessage = String . format ( "Unable to make request %s " , clientRequest . address ( ) ) ; /* Log the error . */
logger . error ( errorMessage , e ) ; /* Don ' t send the error to the client if we already handled this , i . e . , timedout already . */
if ( ! clientRequest . isHandled ( ) ) { clientRequest . handled ( ) ; /* Notify the client that there was an error . */
clientRequest . getReceiver ( ) . error ( String . format ( "\"%s\"" , errorMessage ) ) ; }


signature:
public class ProxyServiceImpl { /** * Manage periodic jobs . */
@ QueueCallback ( { } }

implementation: QueueCallbackType . EMPTY , QueueCallbackType . IDLE , QueueCallbackType . LIMIT } ) public void process ( ) { reactor . process ( ) ; time = timer . time ( ) ;


signature:
public class LokateServiceDiscoveryProvider { /** * Create service discovery that can talk via Lokate .
 * @ param configs configs
 * @ return ServiceDiscovery */
public static ServiceDiscovery createLokateServiceDiscovery ( final List < URI > configs ) { } }

implementation: return serviceDiscoveryBuilder ( ) . setServiceDiscoveryProvider ( new LokateServiceDiscoveryProvider ( DiscoveryService . create ( configs ) ) ) . build ( ) ;


signature:
public class ServiceBundleImpl { /** * Handles calling a method
 * @ param methodCall method call */
private void doCall ( MethodCall < Object > methodCall ) { } }

implementation: if ( debug ) { logger . debug ( ServiceBundleImpl . class . getName ( ) , "::doCall() " , methodCall . name ( ) , methodCall . address ( ) , "\n" , methodCall ) ; } try { if ( methodCall . hasCallback ( ) ) { callbackManager . registerCallbacks ( methodCall ) ; } boolean [ ] continueFlag = new boolean [ 1 ] ; methodCall = handleBeforeMethodCall ( methodCall , continueFlag ) ; if ( ! continueFlag [ 0 ] ) { if ( debug ) { logger . debug ( ServiceBundleImpl . class . getName ( ) + "::doCall() " + "Flag from before call handling does not want to continue" ) ; } } else { final Consumer < MethodCall < Object > > methodDispatcher = getMethodDispatcher ( methodCall ) ; methodDispatcher . accept ( methodCall ) ; } } catch ( Exception ex ) { Response < Object > response = new ResponseImpl < > ( methodCall , ex ) ; this . responseQueue . sendQueue ( ) . sendAndFlush ( response ) ; }


signature:
public class ServiceBundleImpl { /** * Add a client to this bundle .
 * @ param object the client we want to add . */
@ Override public ServiceBundle addService ( Object object ) { } }

implementation: if ( debug ) { logger . debug ( "ServiceBundleImpl::addServiceObject(object)- service added" ) ; } addServiceObject ( null , object ) ; return this ;


signature:
public class ServiceBundleImpl { /** * Add a client to this bundle .
 * @ param serviceObject the client we want to add . */
@ Override public ServiceBundle addServiceWithQueueCallBackHandlers ( final Object serviceObject , final QueueCallBackHandler ... queueCallBackHandlers ) { } }

implementation: if ( debug ) { logger . debug ( "ServiceBundleImpl::addServiceObject(object)- service added with handlers" ) ; } addServiceObjectWithQueueCallBackHandlers ( null , serviceObject , queueCallBackHandlers ) ; return this ;


signature:
public class ServiceBundleImpl { /** * Add a client to this bundle , under a certain address .
 * @ param serviceAddress the address of the client
 * @ param serviceObject the client we want to add . */
@ Override public ServiceBundle addServiceObject ( final String serviceAddress , final Object serviceObject ) { } }

implementation: this . addServiceObjectWithQueueCallBackHandlers ( serviceAddress , serviceObject , ( QueueCallBackHandler [ ] ) null ) ; return this ;


signature:
public class ServiceBundleImpl { /** * Call the method . */
@ Override @ SuppressWarnings ( "unchecked" ) public void call ( final MethodCall < Object > methodCall ) { } }

implementation: if ( debug ) { logger . debug ( ServiceBundleImpl . class . getName ( ) + "::call() " + methodCall . name ( ) + " " + " " + methodCall . address ( ) + "\n" + methodCall ) ; } methodSendQueue . send ( methodCall ) ;


signature:
public class ServiceBundleImpl { /** * Creates a proxy interface to a particular client . Given a particular address .
 * @ param serviceInterface client view interface of client
 * @ param myService address or name of client
 * @ param < T > type of client
 * @ return proxy client to client */
@ Override public < T > T createLocalProxy ( final Class < T > serviceInterface , final String myService ) { } }

implementation: final Consumer < MethodCall < Object > > callConsumer = this . serviceMapping . get ( myService ) ; if ( callConsumer == null ) { logger . error ( "Service requested does not exist " + myService ) ; } return factory . createLocalProxy ( serviceInterface , myService , this , beforeMethodSent ) ;


signature:
public class ServiceBundleImpl { /** * Handles before call operation
 * @ param methodCall method call
 * @ param continueCall should we continue the call .
 * @ return call object which could have been transformed */
private MethodCall < Object > beforeMethodCall ( MethodCall < Object > methodCall , boolean [ ] continueCall ) { } }

implementation: if ( this . beforeMethodCall . before ( methodCall ) ) { continueCall [ 0 ] = true ; methodCall = transformBeforeMethodCall ( methodCall ) ; continueCall [ 0 ] = this . beforeMethodCallAfterTransform . before ( methodCall ) ; return methodCall ; } else { continueCall [ 0 ] = false ; } return methodCall ;


signature:
public class ServiceBundleImpl { /** * Handles the before argument transformer .
 * @ param methodCall method call that we might transform
 * @ return method call */
private MethodCall < Object > transformBeforeMethodCall ( MethodCall < Object > methodCall ) { } }

implementation: if ( argTransformer == null || argTransformer == ServiceConstants . NO_OP_ARG_TRANSFORM ) { return methodCall ; } Object arg = this . argTransformer . transform ( methodCall ) ; return MethodCallBuilder . transformed ( methodCall , arg ) ;


signature:
public class ServiceBundleImpl { /** * Stop the client bundle . */
@ SuppressWarnings ( "Convert2streamapi" ) public void stop ( ) { } }

implementation: if ( debug ) { logger . debug ( ServiceBundleImpl . class . getName ( ) , "::stop()" ) ; } methodQueue . stop ( ) ; for ( Stoppable service : servicesToStop ) { service . stop ( ) ; } try { responseQueue . stop ( ) ; } catch ( Exception ex ) { logger . debug ( "" , ex ) ; } try { webResponseQueue . stop ( ) ; } catch ( Exception ex ) { logger . debug ( "" , ex ) ; } if ( systemManager != null ) systemManager . serviceShutDown ( ) ;


signature:
public class ServiceBundleImpl { /** * Handles responses coming back from services . */
public void startReturnHandlerProcessor ( ) { } }

implementation: final SendQueue < Response < Object > > webResponseSendQueue = webResponseQueue . sendQueue ( ) ; responseQueue . startListener ( new ReceiveQueueListener < Response < Object > > ( ) { @ Override public void receive ( Response < Object > response ) { final Request < Object > originatingRequest = response . request ( ) . originatingRequest ( ) ; if ( originatingRequest == null ) { callbackManager . handleResponse ( response ) ; } else if ( originatingRequest instanceof HttpRequest || originatingRequest instanceof WebSocketMessage ) { webResponseSendQueue . send ( response ) ; } else { callbackManager . handleResponse ( response ) ; } } @ Override public void empty ( ) { webResponseSendQueue . flushSends ( ) ; } @ Override public void limit ( ) { webResponseSendQueue . flushSends ( ) ; } @ Override public void shutdown ( ) { } @ Override public void idle ( ) { webResponseSendQueue . flushSends ( ) ; } @ Override public void startBatch ( ) { } } ) ;


signature:
public class DnsSupport { /** * Looks up a service name based on its dns service name . The service part of the SRV DNS Record .
 * @ param dnsServiceName dnsServiceName
 * @ return serviceName */
public String findServiceName ( final String dnsServiceName ) { } }

implementation: String serviceName = dnsServiceNameToServiceName . get ( dnsServiceName ) ; serviceName = serviceName == null ? dnsServiceName : serviceName ; if ( debug ) logger . debug ( "FindServiceName dnsServiceName={} serviceName={}" , dnsServiceName , serviceName ) ; return serviceName ;


signature:
public class DnsSupport { /** * Looks up a dns service name ( SRV DNS RECORD ) .
 * @ param serviceName serviceName
 * @ return DNS service name ( server field + name of SRV DNS Record ) . */
public String findDnsServiceName ( final String serviceName ) { } }

implementation: String dnsServiceName = serviceNameToDNSName . get ( serviceName ) ; dnsServiceName = ( dnsServiceName == null ? serviceName : dnsServiceName ) + postfixURL ; if ( debug ) logger . debug ( "Find DNS_ServiceName dnsServiceName={} serviceName={}" , dnsServiceName , serviceName ) ; return dnsServiceName ;


signature:
public class DnsSupport { /** * Load the service nodes based on the internal service name .
 * DB , Ingester , RadarAggregator , etc .
 * @ param callback callback
 * @ param serviceName serviceName */
public void loadServiceEndpointsByServiceName ( final Callback < List < EndpointDefinition > > callback , final String serviceName ) { } }

implementation: loadServiceEndpointsByDNSService ( callback , findDnsServiceName ( serviceName ) ) ;


signature:
public class DnsSupport { /** * Load the services nodes by its " $ { SRV . service } $ { SRV . name } " .
 * @ param callback callback
 * @ param serviceURL serviceURL */
public void loadServiceEndpointsByDNSService ( final Callback < List < EndpointDefinition > > callback , final String serviceURL ) { } }

implementation: final DnsClient dnsClient = dnsClientProvider . get ( ) ; dnsClient . resolveSRV ( serviceURL , event -> { if ( event . succeeded ( ) ) { if ( debug ) logger . debug ( "loadServiceEndpointsByDNSService SUCCESS serviceURL={} " , serviceURL ) ; callback . resolve ( convertEndpoints ( event . result ( ) ) ) ; } else { Throwable error = event . cause ( ) ; logger . info ( "loadServiceEndpointsByDNSService FAILURE  " + serviceURL , error ) ; attemptRecover ( callback , serviceURL , error ) ; } } ) ;


signature:
public class DnsSupport { /** * Converts list of SrvRecord ( s ) to list of EndpointDefinition ( s ) .
 * @ param results of SrvRecord to convert to EndpointDefinition ( s )
 * @ return list of EndpointDefinition */
private List < EndpointDefinition > convertEndpoints ( final List < SrvRecord > results ) { } }

implementation: return results . stream ( ) . map ( this :: convertSrvRecordToEndpointDefinition ) . collect ( Collectors . < EndpointDefinition > toList ( ) ) ;


signature:
public class DnsSupport { /** * Convert a single srvRecord into an EndpointDefinition .
 * @ param srvRecord srvRecord
 * @ return EndpointDefinition from srvRecord */
private EndpointDefinition convertSrvRecordToEndpointDefinition ( final SrvRecord srvRecord ) { } }

implementation: return new EndpointDefinition ( findServiceName ( srvRecord . service ( ) ) , srvRecord . target ( ) , srvRecord . port ( ) ) ;


signature:
public class CorsResponseDecorator { /** * - - - - - CORS Response headers */
@ Override public boolean decorateTextResponse ( HttpTextResponseHolder responseHolder , String requestPath , String requestMethod , int code , String contentType , String payload , MultiMap < String , String > responseHeaders , MultiMap < String , String > requestHeaders , MultiMap < String , String > requestParams ) { } }

implementation: boolean passedCorsCheck = checkCorsAndContinue ( new HttpRequestHolder ( contentType , requestMethod , payload . getBytes ( ) , requestPath , requestHeaders , requestParams ) , new HttpResponseHolder ( responseHeaders ) ) ; return passedCorsCheck ;


signature:
public class CorsResponseDecorator { /** * Handles a CORS request of type { @ link CORSRequestType } . SIMPLE .
 * @ param request request
 * @ param response response
 * @ return is there a CORS simple handler for this request or response . */
protected boolean handleSimpleCORS ( final HttpRequestHolder request , final HttpResponseHolder response ) { } }

implementation:
CorsResponseDecorator . CORSRequestType requestType = checkRequestType ( request ) ; if ( ! ( requestType == CorsResponseDecorator . CORSRequestType . SIMPLE || requestType == CorsResponseDecorator . CORSRequestType . ACTUAL ) ) { throw new IllegalArgumentException ( CorsSupport . CORS_WRONG_TYPE_2 ) ; // TODO : String replacement
} final String origin = request . getHeaders ( ) . get ( CorsResponseDecorator . REQUEST_HEADER_ORIGIN ) ; final RequestMethod method = RequestMethod . valueOf ( request . getMethod ( ) ) ; // Section 6.1.2
if ( ! isOriginAllowed ( origin ) ) { handleInvalidCORS ( request , response ) ; return false ; } if ( ! corsSupport . getAllowedMethods ( ) . contains ( method ) ) { handleInvalidCORS ( request , response ) ; return false ; } // Section 6.1.3
// Add a single Access - Control - Allow - Origin header .
if ( anyOriginAllowed && ! corsSupport . isAllowCredentials ( ) ) { // If resource doesn ' t support credentials and if any origin is
// allowed
// to make CORS request , return header with ' * ' .
response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , "*" ) ; } else { // If the resource supports credentials add a single
// Access - Control - Allow - Origin header , with the value of the Origin
// header as value .
response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , origin ) ; } // Section 6.1.3
// If the resource supports credentials , add a single
// Access - Control - Allow - Credentials header with the case - sensitive
// string " true " as value .
if ( corsSupport . isAllowCredentials ( ) ) { response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS , "true" ) ; } // Section 6.1.4
// If the list of exposed headers is not empty add one or more
// Access - Control - Expose - headers headers , with as values the header
// field names given in the list of exposed headers .
if ( ( corsSupport . getExposedHeaders ( ) != null ) && ( corsSupport . getExposedHeaders ( ) . size ( ) > 0 ) ) { String exposedHeadersString = join ( corsSupport . getExposedHeaders ( ) , "," ) ; response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS , exposedHeadersString ) ; } return true ;


signature:
public class CorsResponseDecorator { /** * Handles CORS pre - flight request .
 * @ param request request
 * @ param response response
 * @ return return true if pre flight handler . */
protected boolean handlePreflightCORS ( final HttpRequestHolder request , final HttpResponseHolder response ) { } }

implementation:
CORSRequestType requestType = checkRequestType ( request ) ; if ( requestType != CORSRequestType . PRE_FLIGHT ) { throw new IllegalArgumentException ( CorsSupport . CORS_WRONG_TYPE_2 ) ; // TODO : String replace into above CORSRequestType . PRE _ FLIGHT . name ( ) . toLowerCase ( Locale . ENGLISH ) ) ) ;
} final String origin = request . getHeaders ( ) . get ( CorsResponseDecorator . REQUEST_HEADER_ORIGIN ) ; // Section 6.2.2
if ( ! isOriginAllowed ( origin ) ) { handleInvalidCORS ( request , response ) ; return false ; } // Section 6.2.3
String accessControlRequestMethod = request . getHeaders ( ) . get ( CorsResponseDecorator . REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD ) ; if ( accessControlRequestMethod == null ) { handleInvalidCORS ( request , response ) ; return false ; } else { accessControlRequestMethod = accessControlRequestMethod . trim ( ) ; } // Section 6.2.4
String accessControlRequestHeadersHeader = request . getHeaders ( ) . get ( CorsResponseDecorator . REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS ) ; List < String > accessControlRequestHeaders = new LinkedList < > ( ) ; if ( accessControlRequestHeadersHeader != null && ! accessControlRequestHeadersHeader . trim ( ) . isEmpty ( ) ) { String [ ] headers = accessControlRequestHeadersHeader . trim ( ) . split ( "," ) ; for ( String header : headers ) { accessControlRequestHeaders . add ( header . trim ( ) . toLowerCase ( Locale . ENGLISH ) ) ; } } // Section 6.2.5
if ( ! corsSupport . getAllowedHeaders ( ) . contains ( accessControlRequestMethod ) ) { handleInvalidCORS ( request , response ) ; return false ; } // Section 6.2.6
if ( ! accessControlRequestHeaders . isEmpty ( ) ) { for ( String header : accessControlRequestHeaders ) { if ( ! corsSupport . getAllowedHeaders ( ) . contains ( header ) ) { handleInvalidCORS ( request , response ) ; return false ; } } } // Section 6.2.7
if ( corsSupport . isAllowCredentials ( ) ) { response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , origin ) ; response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS , "true" ) ; } else { if ( anyOriginAllowed ) { response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , "*" ) ; } else { response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN , origin ) ; } } // Section 6.2.8
if ( preFlightMaxAge > 0 ) { response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE , String . valueOf ( preFlightMaxAge ) ) ; } // Section 6.2.9
response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS , accessControlRequestMethod ) ; // Section 6.2.10
if ( ( corsSupport . getAllowedHeaders ( ) != null ) && ( ! corsSupport . getAllowedHeaders ( ) . isEmpty ( ) ) ) { response . getHeaders ( ) . add ( CorsResponseDecorator . RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS , join ( corsSupport . getAllowedHeaders ( ) , "," ) ) ; } return true ;


signature:
public class CorsResponseDecorator { /** * Handles a CORS request that violates specification . */
private boolean handleInvalidCORS ( final HttpRequestHolder request , final HttpResponseHolder response ) { } }

implementation:
String origin = request . getHeaders ( ) . get ( CorsResponseDecorator . REQUEST_HEADER_ORIGIN ) ; String method = request . getMethod ( ) ; String accessControlRequestHeaders = request . getHeaders ( ) . get ( REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS ) ; response . getHeaders ( ) . put ( "Content-Type" , "text/plain" ) ; // TODO : Rick note that the integration - point implementation still prevents me from decorating the http response code
// response . code = HttpStatus . SC _ FORBIDDEN ;
if ( log . getLevel ( ) == Level . FINE ) { // Debug so no need for i18n
StringBuilder message = new StringBuilder ( "Invalid CORS request; Origin=" ) ; message . append ( origin ) ; message . append ( ";Method=" ) ; message . append ( method ) ; if ( accessControlRequestHeaders != null ) { message . append ( ";Access-Control-Request-headers=" ) ; message . append ( accessControlRequestHeaders ) ; } log . fine ( message . toString ( ) ) ; } return false ;


signature:
public class CorsResponseDecorator { /** * Determines the request type .
 * @ param request request
 * @ return CORs request type . */
protected CORSRequestType checkRequestType ( final HttpRequestHolder request ) { } }

implementation:
CORSRequestType requestType = CORSRequestType . INVALID_CORS ; if ( request == null ) { throw new IllegalArgumentException ( CorsSupport . CORS_NULL_REQUEST ) ; } String originHeader = request . getHeaders ( ) . get ( REQUEST_HEADER_ORIGIN ) ; // Section 6.1.1 and Section 6.2.1
if ( originHeader != null ) { if ( originHeader . isEmpty ( ) ) { requestType = CORSRequestType . INVALID_CORS ; } else if ( ! isValidOrigin ( originHeader ) ) { requestType = CORSRequestType . INVALID_CORS ; } else if ( isLocalOrigin ( request , originHeader ) ) { return CORSRequestType . NOT_CORS ; } else { String method = request . getMethod ( ) ; if ( method != null ) { if ( "OPTIONS" . equals ( method ) ) { String accessControlRequestMethodHeader = request . getHeaders ( ) . get ( REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD ) ; if ( accessControlRequestMethodHeader != null && ! accessControlRequestMethodHeader . isEmpty ( ) ) { requestType = CORSRequestType . PRE_FLIGHT ; } else if ( accessControlRequestMethodHeader != null && accessControlRequestMethodHeader . isEmpty ( ) ) { requestType = CORSRequestType . INVALID_CORS ; } else { requestType = CORSRequestType . ACTUAL ; } } else if ( "GET" . equals ( method ) || "HEAD" . equals ( method ) ) { requestType = CORSRequestType . SIMPLE ; } else if ( "POST" . equals ( method ) ) { String mediaType = request . getContentType ( ) ; if ( mediaType != null ) { // if ( SIMPLE _ HTTP _ REQUEST _ CONTENT _ TYPE _ VALUES
// . contains ( mediaType ) ) {
// requestType = CORSRequestType . SIMPLE ;
// } else {
// requestType = CORSRequestType . ACTUAL ;
// TODO : Will QBit support non - simple ?
requestType = CORSRequestType . SIMPLE ; } } else { requestType = CORSRequestType . ACTUAL ; } } } } else { requestType = CORSRequestType . NOT_CORS ; } return requestType ;


signature:
public class HttpServerVertx { /** * Handle a vertx request by converting it into a QBit request .
 * @ param request request */
private void handleHttpRequest ( final HttpServerRequest request ) { } }

implementation: if ( debug ) { setupMetrics ( request ) ; logger . debug ( "HttpServerVertx::handleHttpRequest::{}:{}" , request . method ( ) , request . uri ( ) ) ; } switch ( request . method ( ) . toString ( ) ) { case "PUT" : case "POST" : case "OPTIONS" : case "TRACE" : case "DELETE" : case "CONNECT" : handleRequestWithBody ( request ) ; break ; case "HEAD" : case "GET" : handleRequestWithNoBody ( request ) ; break ; default : throw new IllegalStateException ( "method not supported yet " + request . method ( ) ) ; }


signature:
public class BaseServiceQueueImpl { /** * This method is where all of the action is .
 * @ param methodCall methodCall
 * @ param serviceMethodHandler handler */
private boolean doHandleMethodCall ( MethodCall < Object > methodCall , final ServiceMethodHandler serviceMethodHandler ) { } }

implementation:
if ( debug ) { logger . debug ( "ServiceImpl::doHandleMethodCall() METHOD CALL" + methodCall ) ; } if ( callbackManager != null ) { if ( methodCall . hasCallback ( ) && serviceMethodHandler . couldHaveCallback ( methodCall . name ( ) ) ) { callbackManager . registerCallbacks ( methodCall ) ; } } // inputQueueListener . receive ( methodCall ) ;
final boolean continueFlag [ ] = new boolean [ 1 ] ; methodCall = beforeMethodProcessing ( methodCall , continueFlag ) ; if ( continueFlag [ 0 ] ) { if ( debug ) logger . debug ( "ServiceImpl::doHandleMethodCall() before handling stopped processing" ) ; return false ; } Response < Object > response = serviceMethodHandler . receiveMethodCall ( methodCall ) ; if ( response != ServiceConstants . VOID ) { if ( ! afterMethodCall . after ( methodCall , response ) ) { return false ; } // noinspection unchecked
response = responseObjectTransformer . transform ( response ) ; if ( ! afterMethodCallAfterTransform . after ( methodCall , response ) ) { return false ; } if ( debug ) { if ( response . body ( ) instanceof Throwable ) { logger . error ( "Unable to handle call " , ( ( Throwable ) response . body ( ) ) ) ; } } if ( ! responseSendQueue . send ( response ) ) { logger . error ( "Unable to send response {} for method {} for object {}" , response , methodCall . name ( ) , methodCall . objectName ( ) ) ; } } return false ;


signature:
public class Consul { /** * Creates a new client given a host and a port .
 * @ param host The Consul API hostname or IP .
 * @ param port The Consul port .
 * @ return A new client . */
public static Consul consul ( final String host , final int port ) { } }

implementation: try { return new Consul ( new URL ( "http" , host , port , "" ) . toString ( ) ) ; } catch ( MalformedURLException e ) { throw new ConsulException ( "Bad Consul URL" , e ) ; }


signature:
public class DnsClientFromResolveConfSupplier { /** * Get a DNS client .
 * @ return dns client . */
@ Override public DnsClient get ( ) { } }

implementation: final URI uri = addressList . get ( index ) ; try { if ( debug ) logger . debug ( "DnsClient.get port {} host {}" , uri . getPort ( ) , uri . getHost ( ) ) ; return vertx . createDnsClient ( uri . getPort ( ) , uri . getHost ( ) ) ; } catch ( Exception ex ) { logger . error ( "DnsClient.get EXCEPTION " , ex ) ; logger . error ( "DnsClient.get EXCEPTION port {} host {}" , uri . getPort ( ) , uri . getHost ( ) ) ; return getIfErrors ( ) ; }


signature:
public class BasicQueue { /** * This returns a new instance of ReceiveQueue every time you call it
 * so call it only once per thread .
 * @ return received queue */
@ Override public ReceiveQueue < T > receiveQueue ( ) { } }

implementation: if ( debug ) logger . debug ( "ReceiveQueue requested for {}" , name ) ; return new BasicReceiveQueue < > ( queue , pollTimeWait , pollTimeTimeUnit , limit ) ;


signature:
public class BasicQueue { /** * This returns a new instance of SendQueue every time you call it
 * so call it only once per thread .
 * @ return sendQueue . */
@ Override public SendQueue < T > sendQueue ( ) { } }

implementation: if ( debug ) logger . debug ( "SendQueue requested for {}" , name ) ; return sendQueueSupplier . get ( ) ;


signature:
public class Reakt { /** * Converts a Reakt promise into a QBit callback .
 * @ param promise reakt promise
 * @ param < T > type of promise
 * @ return new QBit callback that wraps promise . */
public static < T > Callback < T > convertPromise ( final Promise < T > promise ) { } }

implementation: return convertPromiseToCallback ( promise , CallbackBuilder . callbackBuilder ( ) ) ;


signature:
public class Reakt { /** * Converts a Reakt promise into a QBit callback .
 * Reactor is used to manage timeouts and ensure callback happens on same thread as caller .
 * @ param reactor QBit reactor
 * @ param promise reakt promise
 * @ param < T > type of promise
 * @ return new QBit callback that wraps promise . */
public static < T > Callback < T > convertPromise ( final Reactor reactor , final Promise < T > promise ) { } }

implementation: return convertPromiseToCallback ( promise , reactor . callbackBuilder ( ) ) ;


signature:
public class Reakt { /** * Converts a Reakt callback into a QBit callback .
 * @ param callback reakt callback
 * @ param < T > type of result
 * @ return QBit callback */
public static < T > Callback < T > convertCallback ( final io . advantageous . reakt . CallbackHandler < T > callback ) { } }

implementation: return convertReaktCallbackToQBitCallback ( callback , CallbackBuilder . callbackBuilder ( ) ) ;


signature:
public class Reakt { /** * Converts a Reakt callback into a QBit callback .
 * @ param callback reakt callback
 * @ param < T > type of result
 * @ return QBit callback */
public static < T > io . advantageous . reakt . CallbackHandler < T > convertQBitCallback ( final Callback < T > callback ) { } }

implementation: return result -> { if ( result . failure ( ) ) { callback . onError ( result . cause ( ) ) ; } else { callback . accept ( result . get ( ) ) ; } } ;


signature:
public class Reakt { /** * Converts a Reakt callback into a QBit callback .
 * Reactor is used to manage timeouts and ensure callback happens on same thread as caller .
 * @ param reactor QBit reactor
 * @ param callback reakt callback
 * @ param < T > type of result
 * @ return QBit callback */
public static < T > Callback < T > convertCallback ( final Reactor reactor , final io . advantageous . reakt . CallbackHandler < T > callback ) { } }

implementation: return convertReaktCallbackToQBitCallback ( callback , reactor . callbackBuilder ( ) ) ;


signature:
public class Reakt { /** * Creates a QBit callback based on promise created .
 * @ param promiseConsumer promise consumer
 * @ param < T > T
 * @ return QBit callback */
public < T > Callback < T > callback ( final Consumer < Promise < T > > promiseConsumer ) { } }

implementation: Promise < T > promise = Promises . promise ( ) ; promiseConsumer . accept ( promise ) ; return Reakt . convertPromise ( promise ) ;


signature:
public class StatusEndpoint { /** * Retrieves the host / port of the Consul leader .
 * GET / v1 / status / leader
 * @ return The host / port of the leader . */
public String getLeader ( ) { } }

implementation: final URI uri = createURI ( "/leader" ) ; final HttpRequestBuilder httpRequestBuilder = RequestUtils . getHttpRequestBuilder ( null , null , RequestOptions . BLANK , "" ) ; final HTTP . Response httpResponse = HTTP . getResponse ( uri + "?" + httpRequestBuilder . paramString ( ) ) ; if ( httpResponse . code ( ) != 200 ) { die ( "Unable to retrieve the leader" , uri , httpResponse . code ( ) , httpResponse . body ( ) ) ; } return fromJson ( httpResponse . body ( ) , String . class ) . replace ( "\"" , "" ) . trim ( ) ;


signature:
public class StatusEndpoint { /** * Retrieves a list of host / ports for raft peers .
 * GET / v1 / status / peers
 * @ return List of host / ports for raft peers . */
public List < String > getPeers ( ) { } }

implementation: final URI uri = createURI ( "/peers" ) ; final HttpRequestBuilder httpRequestBuilder = RequestUtils . getHttpRequestBuilder ( null , null , RequestOptions . BLANK , "" ) ; final HTTP . Response httpResponse = HTTP . getResponse ( uri + "?" + httpRequestBuilder . paramString ( ) ) ; if ( httpResponse . code ( ) != 200 ) { die ( "Unable to get the peers" , uri , httpResponse . code ( ) , httpResponse . body ( ) ) ; } return fromJsonArray ( httpResponse . body ( ) , String . class ) ;


signature:
public class ServiceDiscoveryImpl { /** * Iterate through the health service queue and load the services . */
private void loadHealthyServices ( ) { } }

implementation:
try { String serviceName = doneQueue . poll ( ) ; while ( serviceName != null ) { final String serviceNameToFetch = serviceName ; /* Don ' t load the service if it is already being loaded . */
if ( ! serviceNamesBeingLoaded . contains ( serviceNameToFetch ) ) { serviceNamesBeingLoaded . add ( serviceNameToFetch ) ; executorService . submit ( ( ) -> { /* Loading a service pool might take a while so
 the actual load operation happens in its own thread . */
doLoadHealthServices ( serviceNameToFetch ) ; } ) ; } serviceName = doneQueue . poll ( ) ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; }


signature:
public class ServiceDiscoveryImpl { /** * Loads the service from the remote service registry ( i . e . , consul ) .
 * @ param serviceNameToFetch service that we are loading a pool for . */
private void doLoadHealthServices ( final String serviceNameToFetch ) { } }

implementation:
try { final List < EndpointDefinition > healthyServices = provider . loadServices ( serviceNameToFetch ) ; populateServiceMap ( serviceNameToFetch , healthyServices ) ; } catch ( Exception ex ) { doFailOverHealthServicesLoad ( serviceNameToFetch , ex ) ; } finally { /* Remove the service from the serviceNamesBeingLoaded
 SET and add it back to the work pool
 to get loaded again .
 We are constantly loading services through long polling for changes . */
serviceNamesBeingLoaded . remove ( serviceNameToFetch ) ; }


signature:
public class ServiceDiscoveryImpl { /** * If the primary load failed , we could have a backup provider registered .
 * @ param serviceNameToFetch service pool to fetch
 * @ param ex */
private void doFailOverHealthServicesLoad ( final String serviceNameToFetch , Exception ex ) { } }

implementation:
/* If there is a backup provider , load from there . */
if ( backupProvider != null ) { if ( debug ) logger . debug ( "ServiceDiscoveryImpl::loadHealthyServices " + "Error while loading healthy" + " services for " + serviceNameToFetch , ex ) ; final List < EndpointDefinition > healthyServices = backupProvider . loadServices ( serviceNameToFetch ) ; populateServiceMap ( serviceNameToFetch , healthyServices ) ; serviceNamesBeingLoaded . remove ( serviceNameToFetch ) ; } else { logger . error ( "ServiceDiscoveryImpl::loadHealthyServices " + "Error while loading healthy" + " services for " + serviceNameToFetch , ex ) ; } Sys . sleep ( 10_000 ) ; // primary is down so slow it down so we don ' t flow the system with updates of service pools .


signature:
public class ServiceDiscoveryImpl { /** * Populate the service map .
 * Look up the service pool .
 * Apply the healthy services so the pool can see if there were changes ( additions , removal , etc . )
 * @ param serviceName service name
 * @ param healthyServices list of healthy services that we just loaded . */
private void populateServiceMap ( final String serviceName , final List < EndpointDefinition > healthyServices ) { } }

implementation:
final ServicePool servicePool = servicePool ( serviceName ) ; /* If there were changes then send a service pool change event on the event channel . */
if ( servicePool . setHealthyNodes ( healthyServices ) ) { serviceChangedEventChannel . servicePoolChanged ( serviceName ) ; serviceChangedEventChannel . flushEvents ( ) ; } final BlockingQueue < Callback < List < EndpointDefinition > > > callbacks = callbackMap . get ( serviceName ) ; if ( callbacks != null ) { Callback < List < EndpointDefinition > > callback = callbacks . poll ( ) ; while ( callback != null ) { callback . resolve ( healthyServices ) ; callback = callbacks . poll ( ) ; } }


signature:
public class DnsSingleClientSupplier { /** * Supply an instance of DnsClient .
 * @ return DnsClient . */
@ Override public DnsClient get ( ) { } }

implementation: if ( debug ) logger . debug ( "DnsSingleClientSupplier.get()::host = {}, port = {}" , host , port ) ; return vertx . createDnsClient ( port , host ) ;


signature:
public class Reactor { /** * Add a task that gets repeated .
 * @ param repeatEvery repeat Every time period
 * @ param timeUnit unit for repeatEvery
 * @ param task task to perform */
public void addRepeatingTask ( final long repeatEvery , final TimeUnit timeUnit , final Runnable task ) { } }

implementation: repeatingTasks . add ( new RepeatingTask ( task , timeUnit , repeatEvery ) ) ;


signature:
public class Reactor { /** * Add a task that gets executed once .
 * @ param fireAfter run task after time period
 * @ param timeUnit unit for fireAfter
 * @ param task task to perform */
public void addOneShotAfterTask ( final long fireAfter , final TimeUnit timeUnit , final Runnable task ) { } }

implementation: fireOnceAfterTasks . add ( new FireOnceTask ( task , timeUnit , fireAfter ) ) ;


signature:
public class Reactor { /** * Add a task that gets repeated .
 * @ param repeatEvery repeat Every time period
 * @ param task task to perform */
public void addRepeatingTask ( final Duration repeatEvery , final Runnable task ) { } }

implementation: repeatingTasks . add ( new RepeatingTask ( task , repeatEvery . getTimeUnit ( ) , repeatEvery . getDuration ( ) ) ) ;


signature:
public class Reactor { /** * Create a callback
 * @ param callback callback
 * @ param timeoutDuration timeout duration
 * @ param timeUnit time unit of timeout
 * @ param onTimeout onTimeout handler
 * @ param onError on error handler
 * @ param < T > T
 * @ return callback */
public < T > AsyncFutureCallback < T > callbackWithTimeoutAndErrorHandlerAndOnTimeout ( final Callback < T > callback , final long timeoutDuration , final TimeUnit timeUnit , final Runnable onTimeout , final Consumer < Throwable > onError ) { } }

implementation: final AtomicReference < AsyncFutureCallback < T > > ref = new AtomicReference < > ( ) ; final AsyncFutureCallbackImpl < T > asyncFutureCallback = AsyncFutureCallbackImpl . callback ( callback , currentTime , timeUnit . toMillis ( timeoutDuration ) , createOnFinished ( ref ) , onTimeout , onError ) ; ref . set ( asyncFutureCallback ) ; addCallback ( asyncFutureCallback ) ; return asyncFutureCallback ;


signature:
public class Reactor { /** * Create a callback
 * @ param cls cls
 * @ param callback callback
 * @ param timeoutDuration timeout duration
 * @ param timeUnit timeUnit for timeout
 * @ param < T > T
 * @ return callback */
public < T > AsyncFutureCallback < T > callbackWithTimeout ( Class < T > cls , final Callback < T > callback , final long timeoutDuration , final TimeUnit timeUnit ) { } }

implementation: return callbackWithTimeout ( callback , timeoutDuration , timeUnit ) ;


signature:
public class Reactor { /** * Create a callback
 * @ param cls cls
 * @ param callback callback
 * @ param timeoutDuration timeout duration
 * @ param timeUnit timeUnit for timeout
 * @ param onError onError handler
 * @ param < T > T
 * @ return callback */
public < T > AsyncFutureCallback < T > callbackWithTimeoutAndErrorHandler ( Class < T > cls , final Callback < T > callback , final long timeoutDuration , final TimeUnit timeUnit , final Consumer < Throwable > onError ) { } }

implementation: return callbackWithTimeoutAndErrorHandler ( callback , timeoutDuration , timeUnit , onError ) ;


signature:
public class Reactor { /** * Remove a callback from the list of callbacks that we are managing .
 * @ param asyncFutureCallback asyncFutureCallback
 * @ param < T > T
 * @ return the callback that we removed . */
public < T > AsyncFutureCallback < T > removeFuture ( AsyncFutureCallback < T > asyncFutureCallback ) { } }

implementation: this . removeFutureQueue . offer ( asyncFutureCallback ) ; return asyncFutureCallback ;


signature:
public class Reactor { /** * Utility method to create a coordinator .
 * @ param coordinator coordinator
 * @ param startTime startTime
 * @ param timeoutDuration timeoutDuration
 * @ param timeUnit timeUnit
 * @ param timeOutHandler timeOutHandler
 * @ param finishedHandler finishedHandler
 * @ return callback coordinator */
public CallbackCoordinator coordinateWithTimeout ( final CallbackCoordinator coordinator , final long startTime , final long timeoutDuration , final TimeUnit timeUnit , final Runnable timeOutHandler , final Runnable finishedHandler ) { } }

implementation: final long timeoutDurationMS = timeUnit . toMillis ( timeoutDuration ) ; final long theStartTime = startTime == - 1 ? currentTime : startTime ; final CallbackCoordinator wrapper = new CallbackCoordinator ( ) { AtomicBoolean done = new AtomicBoolean ( ) ; @ Override public boolean checkComplete ( ) { if ( done . get ( ) ) { return true ; } if ( coordinator . checkComplete ( ) ) { done . set ( true ) ; } return done . get ( ) ; } public boolean timedOut ( long now ) { if ( startTime ( ) == - 1 || timeOutDuration ( ) == - 1 ) { return false ; } if ( ( now - startTime ( ) ) > timeOutDuration ( ) ) { if ( ! done . get ( ) ) { timeOutHandler . run ( ) ; done . set ( true ) ; } return true ; } else { return false ; } } @ Override public long timeOutDuration ( ) { return coordinator . timeOutDuration ( ) == - 1 ? timeoutDurationMS : coordinator . timeOutDuration ( ) ; } @ Override public long startTime ( ) { return coordinator . startTime ( ) == - 1 ? theStartTime : coordinator . startTime ( ) ; } public void finished ( ) { if ( checkComplete ( ) ) { removeCoordinator ( this ) ; } if ( finishedHandler != null ) { finishedHandler . run ( ) ; } coordinator . finished ( ) ; } public void cancel ( ) { done . set ( true ) ; removeCoordinator ( this ) ; coordinator . cancel ( ) ; } } ; this . coordinatorQueue . add ( wrapper ) ; return wrapper ;


signature:
public class Reactor { /** * Monitors timeouts . If the callback timed - out trigger it , and then remove callback from the list . */
private void monitorCallBacks ( ) { } }

implementation: if ( futureList . size ( ) > 0 ) { final List < AsyncFutureCallback < ? > > removeList = new ArrayList < > ( futureList . size ( ) ) ; long now = currentTime ; for ( AsyncFutureCallback < ? > callback : futureList ) { if ( callback . isDone ( ) ) { callback . run ( ) ; removeList . add ( callback ) ; } else { if ( callback . checkTimeOut ( now ) ) { removeList . add ( callback ) ; } } } futureList . removeAll ( removeList ) ; }


signature:
public class Reactor { /** * Monitors Callback Coordinators .
 * Trigger timeouts if needed and remove coordinators from list that timed out . */
private void monitorCallbackCoordinators ( ) { } }

implementation: if ( coordinatorList . size ( ) > 0 ) { final List < CallbackCoordinator > removeList = new ArrayList < > ( coordinatorList . size ( ) ) ; for ( CallbackCoordinator callable : coordinatorList ) { if ( callable . checkComplete ( ) ) { callable . finished ( ) ; removeList . add ( callable ) ; } else if ( callable . timedOut ( currentTime ) ) { removeList . add ( callable ) ; } } coordinatorList . removeAll ( removeList ) ; }


signature:
public class Reactor { /** * Used for quickly delegating one callback to another .
 * This allows one liners so you don ' t have to create a builder for this common case .
 * @ param operationDescription Describe the operation for logging
 * @ param callback callback to delegate error and timeouts too .
 * @ param logger logger to log errors and timeouts .
 * @ param < T > Generic type
 * @ return wrapped callback that is tied to this reactor . */
public < T > Callback < T > wrapCallback ( final String operationDescription , final Callback < T > callback , final Logger logger ) { } }

implementation:
/* Set the callback to delegate to this callback . */
Callback < T > reactiveCallback = callbackBuilder ( ) . withCallback ( new Callback < T > ( ) { @ Override public void accept ( T t ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "{} returned {}" , operationDescription , t ) ; } callback . resolve ( t ) ; } /* Provide some boiler plate error handling . */
} ) . withErrorHandler ( error -> { logger . error ( String . format ( "ERROR calling %s" , operationDescription ) , error ) ; callback . onError ( error ) ; /* Provide some boiler timeout handling . */
} ) . withTimeoutHandler ( ( ) -> { logger . error ( "TIMEOUT calling {}" , operationDescription ) ; callback . onTimeout ( ) ; } ) . build ( ) ; return reactiveCallback ;


signature:
public class Reactor { /** * Used for quickly delegating one callback to another when the return types are different .
 * This is usually the case if you want to do some transformation of the object and not just return it .
 * This allows one liners so you don ' t have to create a builder for this common case .
 * @ param operationDescription Describe the operation for logging
 * @ param logger logger to log errors and timeouts .
 * @ param errorHandler Callback that does the error handling if the delegated call fails .
 * @ param callback callback to delegate error and timeouts too .
 * @ param < T > Generic type
 * @ return wrapped callback that is tied to this reactor . */
public < T > Callback < T > wrapCallbackErrors ( final String operationDescription , final Callback < T > callback , final Callback < ? > errorHandler , final Logger logger ) { } }

implementation:
return callbackBuilder ( ) . setCallback ( new Callback < T > ( ) { @ Override public void accept ( T t ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "{} returned {}" , operationDescription , t ) ; } callback . resolve ( t ) ; } /* Provide some boiler plate error handling . */
} ) . setOnError ( error -> { logger . error ( String . format ( "ERROR calling %s" , operationDescription ) , error ) ; errorHandler . onError ( error ) ; } ) . setOnTimeout ( ( ) -> { logger . error ( "TIMEOUT calling {}" , operationDescription ) ; errorHandler . onTimeout ( ) ; } ) . build ( ) ;


signature:
public class Reactor { /** * Used for quickly delegating one callback to another .
 * This allows one liners so you don ' t have to create a builder for this common case .
 * @ param operationDescription Describe the operation for logging
 * @ param callback callback to delegate error and timeouts too .
 * @ param logger logger to log errors and timeouts .
 * @ param < T > Generic type
 * @ param timeoutDuration time out duration
 * @ param timeUnit Time Unit
 * @ return wrapped callback that is tied to this reactor . */
public < T > Callback < T > wrapCallbackWithTimeout ( final String operationDescription , final Callback < T > callback , final Logger logger , final TimeUnit timeUnit , final long timeoutDuration ) { } }

implementation: return callbackBuilder ( ) . setCallback ( new Callback < T > ( ) { @ Override public void accept ( T t ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "{} returned {}" , operationDescription , t ) ; } callback . resolve ( t ) ; } } ) . setOnError ( error -> { logger . error ( String . format ( "ERROR calling %s" , operationDescription ) , error ) ; callback . onError ( error ) ; } ) . setOnTimeout ( ( ) -> { logger . error ( "TIMEOUT calling {}" , operationDescription ) ; callback . onTimeout ( ) ; } ) . setTimeoutTimeUnit ( timeUnit ) . setTimeoutDuration ( timeoutDuration ) . build ( ) ;


signature:
public class CatalogEndpoint { /** * Retrieves all datacenters .
 * GET / v1 / catalog / datacenters
 * @ return A list of datacenter names . */
public List < String > getDatacenters ( ) { } }

implementation: URI uri = createURI ( "/datacenters" ) ; HTTP . Response httpResponse = HTTP . getResponse ( uri . toString ( ) ) ; if ( httpResponse . code ( ) == 200 ) { return fromJsonArray ( httpResponse . body ( ) , String . class ) ; } die ( "Unable to retrieve the datacenters" , uri , httpResponse . code ( ) , httpResponse . body ( ) ) ; return Collections . emptyList ( ) ;


signature:
public class CatalogEndpoint { /** * Retrieves all services for a given datacenter with { @ link io . advantageous . consul . domain . option . RequestOptions } .
 * GET / v1 / catalog / services ? dc = { datacenter }
 * @ param requestOptions The Query Options to use .
 * @ return A { @ link io . advantageous . consul . domain . ConsulResponse } containing a map of service name to list of tags . */
public ConsulResponse < Map < String , List < String > > > getServices ( RequestOptions requestOptions ) { } }

implementation: return getServices ( null , null , requestOptions ) ;