text:
// Copyright (c) 2015 Anjul Garg <anjulgarg@live.com>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package com.wings.framework.routing;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wings.framework.errors.SecurityError;
import com.wings.framework.global.View;
import com.wings.framework.internal.DynaCall;
import com.wings.framework.internal.Reporter;
import com.wings.framework.security.CSRF;

public class RouteController
{
	private String className = new String();
	private String methodName = new String();

	/**
	 * Intercepts and compares each url to a predefined route
	 * and invokes the controller, middleware or view
	 * assigned to that route.
	 * It can intercept GET, POST, PUT, DELETE requests.
	 * It also extracts the parameters inside the URL if any.
	 *
	 *
Note:

	 * Calls the Middleware first and Controller after them.
	 *
	 * @param request
	 * @param response
	 * @throws Exception
	 *
	 */
	public RouteController( HttpServletRequest request, HttpServletResponse response )
	{
		switch ( request.getMethod().toUpperCase() )
		{

		case "GET":
			/* MiddleWares First */
			for (String item : Get.middlewareRouteList)
			{
				if( RouteParser.match(item, request) )
				{
					this.invokeController( Get.middlewareList.get(item) );
				}
			}
			/* Controllers Second */
			for (String item : Get.routeList)
			{
				if( RouteParser.match(item, request) )
				{
					this.invokeController( Get.controllerList.get(item) );
					break;
				}
			}

			break;

		case "POST":
			for (String item : Post.middlewareRouteList)
			{
				try
				{
					if( RouteParser.match(item, request) && CSRF.check() )	/* Also Checks for CSRF */
					{
						this.invokeController( Post.middlewareList.get(item) );
					}
				}
				catch ( SecurityError e ) { Reporter.error(e); }
			}
			for (String item : Post.routeList)
			{
				try
				{
					if( RouteParser.match(item, request) && CSRF.check() )	/* Also Checks for CSRF */
					{
						this.invokeController( Post.controllerList.get(item) );
						break;
					}
				}
				catch ( SecurityError e ) { Reporter.error(e); }
			}

			break;

		case "PUT":
			for (String item : Put.middlewareRouteList)
			{
				try
				{
					if( RouteParser.match(item, request) && CSRF.check() )	/* Also Checks for CSRF */
					{
						this.invokeController( Put.middlewareList.get(item) );
					}
				}
				catch ( SecurityError e ) {	Reporter.error(e); }
			}
			for (String item : Put.routeList)
			{
				try
				{
					if( RouteParser.match(item, request) && CSRF.check() )	/* Also Checks for CSRF */
					{
						this.invokeController( Put.controllerList.get(item) );
						break;
					}
				}
				catch ( SecurityError e ) {	Reporter.error(e); }
			}

			break;

		case "DELETE":
			for (String item : Delete.middlewareRouteList)
			{
				try
				{
					if( RouteParser.match(item, request) && CSRF.check() )	/* Also Checks for CSRF */
					{
						this.invokeController( Delete.middlewareList.get(item) );
					}
				}
				catch ( SecurityError e ) { Reporter.error(e); }
			}
			for (String item : Delete.routeList)
			{
				try
				{
					if( RouteParser.match(item, request) && CSRF.check() )	/* Also Checks for CSRF */
					{
						this.invokeController( Delete.controllerList.get(item) );
						break;
					}
				} catch ( SecurityError e ) { Reporter.error(e); }
			}

			break;
		}

	}

	/**
	 * Extracts the Controller name from the Route specified by the user,
	 * and calls that controller using DynaCall which uses Java Reflection.
	 *
	 *
	 * @param controller
	 * @throws Exception
	 *
	 */
	void invokeController( String controller )
	{
		this.className = controller.substring( 0, controller.indexOf("@") );
		this.methodName = controller.substring( controller.indexOf("@")+1, controller.length() );

		if( className.equalsIgnoreCase("view")  )
		{
			View.render( methodName );

		} else if( className.equalsIgnoreCase("redirect")  )
		{
			View.redirect( methodName );
		} else
			DynaCall.method( className, methodName );
	}

}


text:
// __BEGIN_LICENSE__
//  Copyright (c) 2009-2013, United States Government as represented by the
//  Administrator of the National Aeronautics and Space Administration. All
//  rights reserved.
//
//  The NGT platform is licensed under the Apache License, Version 2.0 (the
//  "License"); you may not use this file except in compliance with the
//  License. You may obtain a copy of the License at
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// __END_LICENSE__

// ===========================================================================
// The polygon rasterization code is based on s_pgdraw.c and
// s_pgspan.c from the OpenGL reference implementation
// ===========================================================================

// ===========================================================================
// NOTE: although within a pixel, we currently don't get results
// identical to NVIDIA's OpenGL implementation OpenGL version. This
// may be a difference between the definitions of the pixel center
// (NVIDIA may use the 0.5 pixel offset). We also may be using a
// subtly different transform to the final window coords. Should check
// againt __glUpdateViewport and __glUpdateViewportTransform in
// s_xform.c. Also code in __glim_Ortho. -- LJE
// ===========================================================================

// ===========================================================================
// According to Levoy:
//
//     http://graphics.stanford.edu/courses/cs248-01/scan/scan1.html
//
// SGI "uses a DDA with fixed-point arithmetic. log2N bits of
// sub-pixel precision for an N-pixel line". This seems to be similar
// to the approach taken here for polygon rasterization.
// ===========================================================================

#include <vw/Core/Exception.h>
#include <vw/Core/FundamentalTypes.h>
#include <asp/Core/SoftwareRenderer.h>

#include <iostream>

using namespace std;
using namespace vw;
using namespace stereo;

enum { eShadeFlat = 0x0, eShadeSmooth = 0x1 };

// ===========================================================================
// Constants and enums
// ===========================================================================

// NOTE: double does *NOT* work!
// #define _VW_USE_DOUBLE_
#ifdef _VW_USE_DOUBLE_

#define __TWO_63 9223372036854775808.0
#define __FRACTION(result, f) result = (vw::int64) ((f) * __TWO_63)
#define SHIFT 63
typedef double RealT;

#else

#define __TWO_31 2147483648.0F
#define __FRACTION(result, f) result = (vw::int32) ((f) * __TWO_31)
#define SHIFT 31
typedef float RealT;

#endif

static const int kVerticesPerTriangle = 3;

// ===========================================================================
// Type declarations
// ===========================================================================

// Coordinate structure.  Coordinates contain x, y, z and w.
struct Coords
{
  Coords() {}
  Coords(float coords[2])
  {
    x = coords[0]; y = coords[1]; z = 0.0; w = 1.0;
  }
  RealT x, y, z, w;
};

// Color structure.  Colors are composed of red, green, blue and alpha.
struct Color
{
  Color() {}
  Color(float gray) { r = gray; g = 0.0; b = 0.0; a = 1.0; }
  Color(float color[], int numComponents)
  {
    switch (numComponents)
    {
    case 1:
      r = color[0]; g = 0.0; b = 0.0; a = 1.0;
      return;
    case 3:
      r = color[0]; g = color[1]; b = color[2]; a = 1.0;
      return;
    case 4:
      r = color[0]; g = color[1]; b = color[2]; a = color[3];
      return;
    default:
      r = 0.0; g = 0.0; b = 0.0; a = 1.0;
    }
  }
  RealT r, g, b, a;
};

// Interpolator record for color interpolators.  Used for primary and
// secondary colors;
struct ColorIterator
{
  RealT rLittle, gLittle, bLittle, aLittle;
  RealT rBig, gBig, bBig, aBig;
  RealT drdx, dgdx, dbdx, dadx;
  RealT drdy, dgdy, dbdy, dady;
};

// A fragment is a collection of all the data needed after
// rasterization of a primitive has occurred, but before the data is
// entered into various framebuffers.  The data contained in the
// fragment has been normalized into a form for immediate storage into
// the framebuffer.

struct FragmentInfo
{
  FragmentInfo() {}
  int x, y;                                // Screen x, y
  // Colors of the fragment.  When in colorIndexMode only the r
  // component is valid.
  Color color;
};

// Shader record for iterated objects (lines/triangles).  This keeps
// track of all the various deltas needed to rasterize a triangle.
struct RasterInfo
{
  RasterInfo() {}
  int dxLeftLittle, dxLeftBig;
  int dxLeftFrac;
  int ixLeft, ixLeftFrac;

  int dxRightLittle, dxRightBig;
  int dxRightFrac;
  int ixRight, ixRightFrac;

  RealT area;
  RealT dxAC, dxBC, dyAC, dyBC;

  bool ccw;

  FragmentInfo frag;
  int length;

  ColorIterator  colorIter;

  unsigned int modeFlags;
};

struct GraphicsState
{
  GraphicsState() {}
  float *buffer;
  int numPixels;
  int width;
  int height;

  RasterInfo rasterInfo;
  Color currentFlatColor;
  // The smallest rectangle that is the intersection of the window clip
  // and the scissor clip.  If the scissor box is disabled then this
  // is just the window box. Note that the x0,y0 point is inside the
  // box but that the x1,y1 point is just outside the box.
  int clipX0, clipY0, clipX1, clipY1;
  // The viewport translated into offset window coordinates.  maxx and
  // maxy are one past the edge (an x coord is in if minx <= x <
  // maxx).
  int minx, miny, maxx, maxy;
};

struct Vertex
{
  Vertex(float initCoords[2], float initGray)
    : color(initGray), window(initCoords) {}
  Vertex(float initCoords[2], Color initColor)
    : color(initColor), window(initCoords) {}

  // Current face color in use.
  Color color;
  // Window coordinate. This field is filled in when the window clip
  // coordinate is converted to a drawing surface relative "window"
  // coordinate. NOTE: the window.w coordinate contains 1/clip.w.
  Coords window;
};

// ===========================================================================
// Functions
// ===========================================================================

inline RealT
TriangleArea(RealT dxAC, RealT dxBC, RealT dyAC, RealT dyBC)
{
  RealT area = dxAC * dyBC - dxBC * dyAC;
  return area;
}

static void
SortVertices(Vertex * &a, Vertex * &b, Vertex * &c)
{
  if (*(int *)&a->window.y < *(int *) &b->window.y)
  {
    if (*(int *)&b->window.y < *(int *) &c->window.y)      // Already sorted
    {
      return;
    }
    else
    {
      if (*(int *)&a->window.y < *(int *)&c->window.y)
      {
        Vertex *temp = b;
        b = c;
        c = temp;
      }
      else
      {
        Vertex *temp = a;
        a = c;
        c = b;
        b = temp;
      }
    }
  }
  else
  {
    if (*(int *)&b->window.y < *(int *)&c->window.y)
    {
      if (*(int *)&a->window.y < *(int *)&c->window.y)
      {
        Vertex *temp = a;
        a = b;
        b = temp;
      }
      else
      {
        Vertex *temp = a;
        a = b;
        b = c;
        c = temp;
      }
    }
    else
    {
      Vertex *temp = a;
      a = c;
      c = temp;
    }
   }
}

static void
SetInitialParameters(GraphicsState *gc, const Vertex *a, RealT dx, RealT dy)
{
  RasterInfo *rasterInfo = &gc->rasterInfo;
  RealT big = rasterInfo->dxLeftBig;
  RealT little = rasterInfo->dxLeftLittle;
  const Color *vertexColor;
  Color *fragColor;
  ColorIterator *iter;
  unsigned int modeFlags = rasterInfo->modeFlags;

  if (big > little)
  {
    if (modeFlags & eShadeSmooth)
    {
      vertexColor = &a->color;
      fragColor = &rasterInfo->frag.color;
      iter = &rasterInfo->colorIter;

      fragColor->r = vertexColor->r + dx*iter->drdx + dy*iter->drdy;
      iter->rLittle = iter->drdy + little * iter->drdx;
      iter->rBig = iter->rLittle + iter->drdx;
    }
  }
  else
  {
    if (modeFlags & eShadeSmooth)
    {
      vertexColor = &a->color;
      fragColor = &rasterInfo->frag.color;
      iter = &rasterInfo->colorIter;

      fragColor->r = vertexColor->r + dx*iter->drdx + dy*iter->drdy;
      iter->rLittle = iter->drdy + little * iter->drdx;
      iter->rBig = iter->rLittle - iter->drdx;
    }
  }
}

static void
DrawFlatGraySpan(GraphicsState *gc)
{
  // Evaluate the clipping in the X direction
  int length = gc->rasterInfo.length;
  int x = gc->rasterInfo.frag.x;
  if ( x < gc->clipX0 ) { // Check to see if the line goes off the left
    length += x - gc->clipX0;
    x = gc->clipX0;
  }
  if ( x + length > gc->clipX1 ) { // Check to see the line goes off
                                   // the right
    length -= x + length - gc->clipX1;
  }

  // Check to see if we just removed this line
  if ( length < 1 ) return;

  std::fill_n(&(gc->buffer[gc->rasterInfo.frag.y * gc->width + x]),
              length, float(gc->rasterInfo.frag.color.r));
}

static void
DrawGraySpan(GraphicsState *gc) {
  RealT gray = gc->rasterInfo.frag.color.r;
  RealT drdx = gc->rasterInfo.colorIter.drdx;

  // Evaluate the clipping in the X direction
  int length = gc->rasterInfo.length;
  int x = gc->rasterInfo.frag.x;
  if ( x < gc->clipX0 ) { // Check to see if the line goes off the left
    int difference = gc->clipX0 - x;
    length -= difference;
    x = gc->clipX0;
    gray += RealT(difference) * drdx;
  }
  if ( x + length > gc->clipX1 ) { // Check to see the line goes off
                                   // the right
    length -= x + length - gc->clipX1;
  }

  // Check to see if we just removed this line
  if ( length < 1 ) return;

  float *span = &(gc->buffer[gc->rasterInfo.frag.y * gc->width + x ] );

  for (int i = length; i; --i) {
    *span++ = float(gray);
    gray += drdx;
  }
}

// In the SnapX* and FillSubTriangle routines, 1s31.1s31 fixed point
// arithmetic is used with the integer and fractional portions carried
// in separate ints (e.g., ixLeft and ixLeftFrac)
static void
SnapXLeft(GraphicsState *gc, RealT xLeft, RealT dxdyLeft)
{
  RealT little, dx;
  int ixLeft, ixLeftFrac, frac, ilittle, ibig;

  ixLeft = (int) xLeft;
  dx = xLeft - ixLeft;
  __FRACTION(ixLeftFrac, dx);

  // Is the following right? Seems like it should be ixLeft - (...) --LJE
  gc->rasterInfo.ixLeft = ixLeft + (((unsigned int) ixLeftFrac) >> SHIFT);
  gc->rasterInfo.ixLeftFrac = ixLeftFrac & ~0x80000000;

  // Compute big and little steps
  ilittle = (int) dxdyLeft;
  little = (RealT) ilittle;
  if (dxdyLeft < 0) {
    ibig = ilittle - 1;
    dx = little - dxdyLeft;
    // Here we know ilittle and ibig are not going to be zero, and
    // that frac will be negative, so we can just negate frac, to get
    // things in our standard form --LJE
    __FRACTION(frac, dx);
    gc->rasterInfo.dxLeftFrac = -frac;
  } else {
    ibig = ilittle + 1;
    dx = dxdyLeft - little;
    __FRACTION(frac, dx);
    gc->rasterInfo.dxLeftFrac = frac;
  }

  gc->rasterInfo.dxLeftLittle = ilittle;
  gc->rasterInfo.dxLeftBig = ibig;
}

static void
SnapXRight(RasterInfo *rasterInfo, RealT xRight, RealT dxdyRight)
{
  RealT little, big, dx;
  int ixRight, ixRightFrac, frac;

  ixRight = (int) xRight;
  dx = xRight - ixRight;
  __FRACTION(ixRightFrac, dx);

  // Is the following right? Seems like it should be ixRight - (...) -LJE
  rasterInfo->ixRight = ixRight + (((unsigned int) ixRightFrac) >> SHIFT);
  rasterInfo->ixRightFrac = ixRightFrac & ~0x80000000;

  // Compute big and little steps
  little = (RealT) ((int) dxdyRight);

  if (dxdyRight < 0)
  {
    big = little - 1;
    dx = little - dxdyRight;
    __FRACTION(frac,dx);
    rasterInfo->dxRightFrac = -frac;
  }
  else
  {
    big = little + 1;
    dx = dxdyRight - little;
    __FRACTION(frac,dx);
    rasterInfo->dxRightFrac = frac;
  }

  rasterInfo->dxRightLittle = (int) little;
  rasterInfo->dxRightBig = (int) big;
}

static void
FillSubTriangle(GraphicsState *gc,  int iyBottom, int iyTop)
{
  int ixLeft, ixRight;
  int ixLeftFrac, ixRightFrac;
  int dxLeftFrac, dxRightFrac;
  int dxLeftLittle, dxRightLittle;
  int dxLeftBig, dxRightBig;
  int spanWidth, clipY0, clipY1;
  unsigned int modeFlags;
  void (*processSpan)(GraphicsState *);

  ixLeft = gc->rasterInfo.ixLeft;
  ixLeftFrac = gc->rasterInfo.ixLeftFrac;
  ixRight = gc->rasterInfo.ixRight;
  ixRightFrac = gc->rasterInfo.ixRightFrac;
  clipY0 = gc->clipY0;
  clipY1 = std::min( gc->clipY1, iyTop );
  dxLeftFrac = gc->rasterInfo.dxLeftFrac;
  dxLeftBig = gc->rasterInfo.dxLeftBig;
  dxLeftLittle = gc->rasterInfo.dxLeftLittle;
  dxRightFrac = gc->rasterInfo.dxRightFrac;
  dxRightBig = gc->rasterInfo.dxRightBig;
  dxRightLittle = gc->rasterInfo.dxRightLittle;
  modeFlags = gc->rasterInfo.modeFlags;
  //  gc->rasterInfo.cfb = gc->drawBuffer;

  if (modeFlags & eShadeSmooth)
    processSpan = DrawGraySpan;
  else
    processSpan = DrawFlatGraySpan;

  while (iyBottom < clipY1)
  {
    spanWidth = ixRight - ixLeft;
    // Only render spans that have non-zero width and which are not
    // scissored out vertically.
    if ((spanWidth > 0) && (iyBottom >= clipY0) ) {
      gc->rasterInfo.frag.x = ixLeft;
      gc->rasterInfo.frag.y = iyBottom;
      gc->rasterInfo.length = spanWidth;
      processSpan(gc);
    }

    // Advance right edge fixed point, adjusting for carry
    ixRightFrac += dxRightFrac;
    if (ixRightFrac < 0)            // Carry/Borrow'd. Use large step
    {
      ixRight += dxRightBig;
      ixRightFrac &= ~0x80000000;
    }
    else                            // Use small step
    {
      ixRight += dxRightLittle;
    }

    iyBottom++;
    ixLeftFrac += dxLeftFrac;
    if (ixLeftFrac < 0)             // Carry/Borrow'd. Use large step
    {
      ixLeft += dxLeftBig;
      ixLeftFrac &= ~0x80000000;

      if (modeFlags & eShadeSmooth)
        gc->rasterInfo.frag.color.r += gc->rasterInfo.colorIter.rBig;
    }
    else                            // Use small step
    {
      ixLeft += dxLeftLittle;
      if (modeFlags & eShadeSmooth)
        gc->rasterInfo.frag.color.r += gc->rasterInfo.colorIter.rLittle;
    }
  }
  gc->rasterInfo.ixLeft = ixLeft;
  gc->rasterInfo.ixLeftFrac = ixLeftFrac;
  gc->rasterInfo.ixRight = ixRight;
  gc->rasterInfo.ixRightFrac = ixRightFrac;
}

static void FillTriangle(GraphicsState *gc, Vertex *a, Vertex *b, Vertex *c) {
  RealT area, oneOverArea, t1, t2, t3, t4;
  RealT dxAC, dxBC, dyAC, dyBC;
  RealT dxAB, dyAB;
  RealT dx, dy, dxdyLeft, dxdyRight;
  Color *aColor, *bColor;
  int aIY, bIY, cIY;
  unsigned int modeFlags;
  bool ccw;                             // was a float for some reason

  // Sort vertices in y.
  SortVertices(a, b, c);

  // Set edge vectors
  dxAC = a->window.x - c->window.x;
  dxBC = b->window.x - c->window.x;
  dyAC = a->window.y - c->window.y;
  dyBC = b->window.y - c->window.y;

  // Compute signed area of the triangle
  area = TriangleArea(dxAC, dxBC, dyAC, dyBC);
  ccw = (area >= 0);   //  ccw = !(* (int *) & area >> 31);

  // Pre-compute one over polygon area
  oneOverArea = (area != 0) ? (1.0 / area) : 0.0;

  // Fetch some stuff we are going to reuse
  modeFlags = gc->rasterInfo.modeFlags;
  aColor = &a->color;                      // & -LJE
  bColor = &b->color;                      // & -LJE

  // Compute delta values for unit changes in x or y for each
  // parameter.
  t1 = dyAC * oneOverArea;
  t2 = dyBC * oneOverArea;
  t3 = dxAC * oneOverArea;
  t4 = dxBC * oneOverArea;

  if (modeFlags & eShadeSmooth)
  {
    RealT drAC, drBC;
    Color *cColor = &c->color;             // & -LJE

    // If gray scale the intensity is carried in the red component
    drAC = aColor->r - cColor->r;
    drBC = bColor->r - cColor->r;
    gc->rasterInfo.colorIter.drdx = drAC * t2 - drBC * t1;
    gc->rasterInfo.colorIter.drdy = drBC * t3 - drAC * t4;
  }
  else
  {
    Color *flatColor = &gc->currentFlatColor; // & -LJE
    gc->rasterInfo.frag.color.r = flatColor->r;
  }

  // Snap each y coordinate to its pixel center
  aIY = (int) (a->window.y);
  bIY = (int) (b->window.y);
  cIY = (int) (c->window.y);

  // This algorithim always fills from bottom to top, left to right.
  // Because of this, ccw triangles are inherently faster because the
  // parameter values need not be recomputed.
  dxAB = a->window.x - b->window.x;
  dyAB = a->window.y - b->window.y;

  if (ccw)
  {
    dxdyLeft = (dyAC != 0.0) ? dxAC / dyAC : 0.0;
    dy = (aIY + 1.0) - a->window.y;
    SnapXLeft(gc, a->window.x + dy*dxdyLeft, dxdyLeft);
    dx = (gc->rasterInfo.ixLeft + 1.0) - a->window.x;
    SetInitialParameters(gc, a, dx, dy);
    if (aIY != bIY)
    {
      dxdyRight = (dyAB != 0.0) ? dxAB / dyAB : 0.0;
      SnapXRight(&gc->rasterInfo, a->window.x + dy*dxdyRight, dxdyRight);
      FillSubTriangle(gc, aIY, bIY);
    }
    if (bIY != cIY)
    {
      dxdyRight = (dyBC != 0.0) ? dxBC / dyBC : 0.0;
      dy = (bIY + 1.0) - b->window.y;
      SnapXRight(&gc->rasterInfo, b->window.x + dy*dxdyRight, dxdyRight);
      FillSubTriangle(gc, bIY, cIY);
    }
  }
  else
  {
    dxdyRight = (dyAC != 0.0) ? dxAC / dyAC : 0.0;
    dy = (aIY + 1.0) - a->window.y;
    SnapXRight(&gc->rasterInfo, a->window.x + dy*dxdyRight, dxdyRight);
    if (aIY != bIY)
    {
      dxdyLeft = (dyAB != 0.0) ? dxAB / dyAB : 0.0;
      SnapXLeft(gc, a->window.x + dy*dxdyLeft, dxdyLeft);
      dx = (gc->rasterInfo.ixLeft + 1.0) - a->window.x;
      SetInitialParameters(gc, a, dx, dy);
      FillSubTriangle(gc, aIY, bIY);
    }
    if (bIY != cIY)
    {
      dxdyLeft = (dyBC != 0.0) ? dxBC / dyBC : 0.0;
      dy = (bIY + 1.0) - b->window.y;
      SnapXLeft(gc, b->window.x + dy*dxdyLeft, dxdyLeft);
      dx = (gc->rasterInfo.ixLeft + 1.0) - b->window.x;
      SetInitialParameters(gc, b, dx, dy);
      FillSubTriangle(gc, bIY, cIY);
    }
  }
}

inline void
MapToWindow(Coords &coords,
            const double ndcMap[3][2],
            double /*x0*/, double /*y0*/, double width, double height,
            Coords &result)
{
  // The separation of NDC and viewport mappings might seem silly
  // right now, but it allows one to modify the projection matrix
  // independently of the final map to window coords and vice
  // versa. Also if we ever do clipping it will be useful.

  // According to the glViewPort specification:
  // xw = (xNDC + 1)(width/2) + x
  // yw = (xNDC + 1)(height/2) + y
  double xNDC = ndcMap[0][0] * coords.x + ndcMap[2][0];
  double yNDC = ndcMap[1][1] * coords.y + ndcMap[2][1];

  result.x = 0.5 * (xNDC + 1.0) * width;
  result.y = 0.5 * (yNDC + 1.0) * height;
}

// ===========================================================================
// Class Member Functions
// ===========================================================================

SoftwareRenderer::SoftwareRenderer(const int width, const int height, float *buffer)
{
  m_numVertexComponents = 0;
  m_vertexPointer = 0;
  m_triangleVertexStep = 0;

  m_numColorComponents = 0;
  m_colorPointer = 0;
  m_triangleColorStep = 0;

  m_bufferWidth = width;
  m_bufferHeight = height;
  m_buffer = buffer;

  double deltaX = double(m_bufferWidth);
  double deltaY = double(m_bufferHeight);

  m_transformViewport[0][1] = m_transformViewport[1][0] = 0.0;
  // scaling
  m_transformViewport[0][0] = deltaX * 0.5;
  m_transformViewport[1][1] = deltaY * 0.5;
  // translation
  m_transformViewport[2][0] = deltaX * 0.5;
  m_transformViewport[2][1] = deltaY * 0.5;

  m_transformNDC[0][1] = m_transformNDC[1][0] = 0.0;
  // scaling
  m_transformNDC[0][0] = 2.0 / deltaX;
  m_transformNDC[1][1] = 2.0 / deltaY;
  // translation
  m_transformNDC[2][0] = -1.0;
  m_transformNDC[2][1] = -1.0;

  m_shadeMode = eShadeSmooth;
  m_currentFlatColor[0] = m_currentFlatColor[1] = m_currentFlatColor[2] = 0.0;

  // FIX ME!!! Put this state info in the software renderer class
  GraphicsState *graphicsState = new GraphicsState;
  graphicsState->buffer = m_buffer;
  graphicsState->currentFlatColor.r = m_currentFlatColor[0];
  graphicsState->width = m_bufferWidth;
  graphicsState->height = m_bufferHeight;
  graphicsState->rasterInfo.modeFlags = eShadeSmooth;
  graphicsState->minx = graphicsState->miny = 0;
  graphicsState->maxx = m_bufferWidth;
  graphicsState->maxy = m_bufferHeight;
  graphicsState->clipX0 = graphicsState->clipY0 = 0;
  graphicsState->clipX1 = m_bufferWidth;
  graphicsState->clipY1 = m_bufferHeight;
  m_graphicsState = graphicsState;
}

// Free up resources that are allocated in the constructor
SoftwareRenderer::~SoftwareRenderer() {

  if (m_graphicsState)
    delete static_cast<GraphicsState*>(m_graphicsState);

}

void
SoftwareRenderer::Ortho2D(const double left, const double right,
                          const double bottom, const double top)
{
  // This takes a 2D point to normalized coordinates (i.e, -1.0 <= x <= 1.0)
  //
  //   [2/(r-l)    0    -(r+l)/(r-l)]
  //   [   0    2/(t-b) -(t+b)/(t-b)]
  //   [   0       0         1     ]
  double deltax = right - left;
  double deltay = top - bottom;

  if ((deltax == 0.0) || (deltay == 0.0))
    vw_throw(LogicErr() << "SoftwareRenderer: Ortho2D failed.  Projection dimensions are zero.");

  m_transformNDC[0][1] = m_transformNDC[1][0] = 0.0;
  m_transformNDC[0][0] = 2.0 / deltax;
  m_transformNDC[1][1] = 2.0 / deltay;
  m_transformNDC[2][0] = -(right + left) / deltax;
  m_transformNDC[2][1] = -(top + bottom) / deltay;
}

void
SoftwareRenderer::Clear(const float value) {
  int bufferSize = m_bufferWidth * m_bufferHeight;
  for (int i = 0; i < bufferSize; ++i)
    m_buffer[i] = value;
}

void
SoftwareRenderer::SetVertexPointer(const int numComponents, float * const vertices)
{
  m_numVertexComponents = numComponents;
  m_triangleVertexStep = kVerticesPerTriangle * m_numVertexComponents;

  m_vertexPointer = vertices;
}

void
SoftwareRenderer::SetColorPointer(const int numComponents, float * const colors)
{
  m_numColorComponents = numComponents;
  m_triangleColorStep = kVerticesPerTriangle * m_numColorComponents;

  m_colorPointer = colors;
}

void
SoftwareRenderer::DrawPolygon(const int startIndex, const int numVertices) {
  if (m_vertexPointer == 0)
    return;

  if ((m_colorPointer == 0) && (m_shadeMode != eShadeFlat))
    return;

  // NOTE: we assume polygons are convex! This allows one to easily
  // fan triangulate them.
  int numTriangles = numVertices - 2;
  float *vertices = &m_vertexPointer[startIndex * m_numVertexComponents];
  float *colors = &m_colorPointer[startIndex * m_numColorComponents];
  int vertexIndex1 = m_numVertexComponents;
  int vertexIndex2 = vertexIndex1 + m_numVertexComponents;
  int colorIndex1 = m_numColorComponents;
  int colorIndex2 = colorIndex1 + m_numColorComponents;
  ::Color color0(&colors[0], m_numColorComponents);
  Vertex vertex0(vertices, color0);

  MapToWindow(vertex0.window, m_transformNDC,
              0.0, 0.0, double(m_bufferWidth), double(m_bufferHeight),
              vertex0.window);

  for (int i = 0; i < numTriangles; i++)
  {
    ::Color color1(&colors[colorIndex1], m_numColorComponents);
    ::Color color2(&colors[colorIndex2], m_numColorComponents);

    Vertex vertex1(&vertices[vertexIndex1], color1);
    Vertex vertex2(&vertices[vertexIndex2], color2);

    MapToWindow(vertex1.window, m_transformNDC,
                0.0, 0.0, double(m_bufferWidth), double(m_bufferHeight),
                vertex1.window);
    MapToWindow(vertex2.window, m_transformNDC,
                0.0, 0.0, double(m_bufferWidth), double(m_bufferHeight),
                vertex2.window);

    FillTriangle((GraphicsState *) m_graphicsState, &vertex0, &vertex1, &vertex2);

    vertexIndex1 += m_triangleVertexStep;
    vertexIndex2 += m_triangleVertexStep;
    colorIndex1 += m_triangleColorStep;
    colorIndex2 += m_triangleColorStep;
  }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

class Google_Service_Dns_ManagedZone extends Google_Collection
{
  protected $collection_key = 'nameServers';
  public $creationTime;
  public $description;
  public $dnsName;
  protected $dnssecConfigType = 'Google_Service_Dns_ManagedZoneDnsSecConfig';
  protected $dnssecConfigDataType = '';
  protected $forwardingConfigType = 'Google_Service_Dns_ManagedZoneForwardingConfig';
  protected $forwardingConfigDataType = '';
  public $id;
  public $kind;
  public $labels;
  public $name;
  public $nameServerSet;
  public $nameServers;
  protected $peeringConfigType = 'Google_Service_Dns_ManagedZonePeeringConfig';
  protected $peeringConfigDataType = '';
  protected $privateVisibilityConfigType = 'Google_Service_Dns_ManagedZonePrivateVisibilityConfig';
  protected $privateVisibilityConfigDataType = '';
  protected $reverseLookupConfigType = 'Google_Service_Dns_ManagedZoneReverseLookupConfig';
  protected $reverseLookupConfigDataType = '';
  protected $serviceDirectoryConfigType = 'Google_Service_Dns_ManagedZoneServiceDirectoryConfig';
  protected $serviceDirectoryConfigDataType = '';
  public $visibility;

  public function setCreationTime($creationTime)
  {
    $this->creationTime = $creationTime;
  }
  public function getCreationTime()
  {
    return $this->creationTime;
  }
  public function setDescription($description)
  {
    $this->description = $description;
  }
  public function getDescription()
  {
    return $this->description;
  }
  public function setDnsName($dnsName)
  {
    $this->dnsName = $dnsName;
  }
  public function getDnsName()
  {
    return $this->dnsName;
  }
  /**
   * @param Google_Service_Dns_ManagedZoneDnsSecConfig
   */
  public function setDnssecConfig(Google_Service_Dns_ManagedZoneDnsSecConfig $dnssecConfig)
  {
    $this->dnssecConfig = $dnssecConfig;
  }
  /**
   * @return Google_Service_Dns_ManagedZoneDnsSecConfig
   */
  public function getDnssecConfig()
  {
    return $this->dnssecConfig;
  }
  /**
   * @param Google_Service_Dns_ManagedZoneForwardingConfig
   */
  public function setForwardingConfig(Google_Service_Dns_ManagedZoneForwardingConfig $forwardingConfig)
  {
    $this->forwardingConfig = $forwardingConfig;
  }
  /**
   * @return Google_Service_Dns_ManagedZoneForwardingConfig
   */
  public function getForwardingConfig()
  {
    return $this->forwardingConfig;
  }
  public function setId($id)
  {
    $this->id = $id;
  }
  public function getId()
  {
    return $this->id;
  }
  public function setKind($kind)
  {
    $this->kind = $kind;
  }
  public function getKind()
  {
    return $this->kind;
  }
  public function setLabels($labels)
  {
    $this->labels = $labels;
  }
  public function getLabels()
  {
    return $this->labels;
  }
  public function setName($name)
  {
    $this->name = $name;
  }
  public function getName()
  {
    return $this->name;
  }
  public function setNameServerSet($nameServerSet)
  {
    $this->nameServerSet = $nameServerSet;
  }
  public function getNameServerSet()
  {
    return $this->nameServerSet;
  }
  public function setNameServers($nameServers)
  {
    $this->nameServers = $nameServers;
  }
  public function getNameServers()
  {
    return $this->nameServers;
  }
  /**
   * @param Google_Service_Dns_ManagedZonePeeringConfig
   */
  public function setPeeringConfig(Google_Service_Dns_ManagedZonePeeringConfig $peeringConfig)
  {
    $this->peeringConfig = $peeringConfig;
  }
  /**
   * @return Google_Service_Dns_ManagedZonePeeringConfig
   */
  public function getPeeringConfig()
  {
    return $this->peeringConfig;
  }
  /**
   * @param Google_Service_Dns_ManagedZonePrivateVisibilityConfig
   */
  public function setPrivateVisibilityConfig(Google_Service_Dns_ManagedZonePrivateVisibilityConfig $privateVisibilityConfig)
  {
    $this->privateVisibilityConfig = $privateVisibilityConfig;
  }
  /**
   * @return Google_Service_Dns_ManagedZonePrivateVisibilityConfig
   */
  public function getPrivateVisibilityConfig()
  {
    return $this->privateVisibilityConfig;
  }
  /**
   * @param Google_Service_Dns_ManagedZoneReverseLookupConfig
   */
  public function setReverseLookupConfig(Google_Service_Dns_ManagedZoneReverseLookupConfig $reverseLookupConfig)
  {
    $this->reverseLookupConfig = $reverseLookupConfig;
  }
  /**
   * @return Google_Service_Dns_ManagedZoneReverseLookupConfig
   */
  public function getReverseLookupConfig()
  {
    return $this->reverseLookupConfig;
  }
  /**
   * @param Google_Service_Dns_ManagedZoneServiceDirectoryConfig
   */
  public function setServiceDirectoryConfig(Google_Service_Dns_ManagedZoneServiceDirectoryConfig $serviceDirectoryConfig)
  {
    $this->serviceDirectoryConfig = $serviceDirectoryConfig;
  }
  /**
   * @return Google_Service_Dns_ManagedZoneServiceDirectoryConfig
   */
  public function getServiceDirectoryConfig()
  {
    return $this->serviceDirectoryConfig;
  }
  public function setVisibility($visibility)
  {
    $this->visibility = $visibility;
  }
  public function getVisibility()
  {
    return $this->visibility;
  }
}


text:
#ifndef _CONVEX_H_
#define _CONVEX_H_

#ifdef _MSC_VER
#pragma warning(disable:4786) // identifier was truncated to '255'
#endif // _MSC_VER

#include <3D/Point.h>
#include "Shape.h"
#include "BBox.h"
#include "Transform.h"

class Convex : public Shape {
public:
  ShapeType getType() const { return CONVEX; }

  virtual ~Convex() {}
  virtual Point support(const Vector& v) const = 0;
  virtual BBox bbox(const Transform& t) const;
};

bool intersect(const Convex& a, const Convex& b,
	       const Transform& a2w, const Transform& b2w,
	       Vector& v);

bool intersect(const Convex& a, const Convex& b, const Transform& b2a,
	       Vector& v);

bool common_point(const Convex& a, const Convex& b,
		  const Transform& a2w, const Transform& b2w,
		  Vector& v, Point& pa, Point& pb);

bool common_point(const Convex& a, const Convex& b, const Transform& b2a,
		  Vector& v, Point& pa, Point& pb);

void closest_points(const Convex&, const Convex&,
		    const Transform&, const Transform&,
		    Point&, Point&);

#endif


text:
package test.tmp;

import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class Test0 {

  @BeforeTest
  public void setup() {
          System.out.println("setup");
  }

  @Test(groups = { "G0" })
  public void test() {
          System.out.println("Test0.test");
  }

  @AfterTest
  public void tearDown() {
          System.out.println("tearDown");
  }

}


text:
package org.kares.math.frec.core;

import org.kares.math.frec.util.RandomHelper;

/**
 * Implements the genetic programming (GP) computing scheme.
 * The most noticeable difference between GA and GP is that
 * in the GP model parents might "survive" multiple generations.
 * This seems more appropriate for genetic computing over
 * syntax trees for data approximation.
 *
 * @author kares
 */
public class GPModelGenetix extends Genetix {

    protected int currentCodeMin;
    protected int currentCodeMax;

    private float reproductProbability = 0.95f;
    private float selectionProbability = 0.85f;

    /**
     */
    public GPModelGenetix() {
        currentCodeMin = GenetixFunction.getFunctionCodeMinLength();
        currentCodeMax = GenetixFunction.getFunctionCodeMaxLength();
    }

    /**
     * @see org.kares.math.frec.core.Genetix#computeInit()
     */
    protected void computeInit() {
        initializeGeneration();
        checkFitnessErrors();
        final int generationSize = getGenerationSize();
        int max = 100;
        while ( getCurrentGeneration().length < generationSize / 2 ) {
            if (--max == 0) break;
            initializeGeneration();
            checkFitnessErrors();
        }
        max = 100;
        while ( getCurrentGeneration().length < generationSize ) {
            if (--max == 0) break;
            final int len = getCurrentGeneration().length;
            super.addNewToGeneration(generationSize - len);
            checkFitnessErrors();
        }
        checkPopulationErrors();
        if ( getCurrentGeneration().length < generationSize ) {
            final int len = getCurrentGeneration().length;
            super.addNewToGeneration(generationSize - len);
        }
        //GenetixFunction.setFunctionCodeLengthLimits(++currentCodeMin, ++currentCodeMax);
    }

    /**
     * @see org.kares.math.frec.core.Genetix#computeNext()
     */
    protected void computeNext() {
        final int generationSize = getGenerationSize();
        int select_size = Math.round(generationSize * getSelectionProbability());
        selectBest(select_size);
        crossGeneration();
        mutateGeneration();
        reproductGeneration();
        addNewToGeneration(generationSize / 10);
        computeFitness();
        checkFitnessErrors();
        checkPopulationErrors();
        if ( getCurrentGeneration().length < generationSize ) {
            final int len = getCurrentGeneration().length;
            super.addNewToGeneration(generationSize - len);
        }
        selectBest(generationSize);
        //if ( getGenerationCounter() % 2 == 0 ) {
        //    GenetixFunction.setFunctionCodeLengthLimits(--currentCodeMin, --currentCodeMax);
        //} else {
        //    GenetixFunction.setFunctionCodeLengthLimits(++currentCodeMin, ++currentCodeMax);
        //}
    }

    /**
     * @see org.kares.math.frec.core.Genetix#initializeGeneration()
     */
    protected void initializeGeneration() {
        final int generationSize = getGenerationSize();
        setCurrentGeneration( generateFunctions(generationSize, 1 + (currentCodeMin + currentCodeMax) / 2) );
        computeFitness();
    }

    /**
     * @see org.kares.math.frec.core.Genetix#mutateGeneration()
     */
    protected void mutateGeneration() {
        final float prob = getMutationProbability();
        GenetixFunction.Tuple newGeneration = getCurrentGenerationAsTuple();
        final GenetixFunction[] currentGeneration = getCurrentGeneration();
        for (int i = 0; i < currentGeneration.length; i++) {
            if ( RandomHelper.randomBoolean(prob) ) {
                GenetixFunction mut = (GenetixFunction) currentGeneration[i].clone();
                mut.mutateFunction( isArbitraryMutations() );
                newGeneration.add(mut);
            }
        }
        setCurrentGeneration(newGeneration);
    }

    /**
     * @see org.kares.math.frec.core.Genetix#crossGeneration()
     */
    protected void crossGeneration() {
        final float prob = getCrossingProbability();
        GenetixFunction.Tuple newGeneration = getCurrentGenerationAsTuple();
        final GenetixFunction[] currentGeneration = getCurrentGeneration();
        final int len = currentGeneration.length;
        for (int i = 0; i < len; i++) {
            if ( RandomHelper.randomBoolean(prob * (1 - i / len)) ) {
                int rnd = RandomHelper.ascRandomInt(len);
                while (rnd == i) rnd = RandomHelper.ascRandomInt(len);
                GenetixFunction new1 = currentGeneration[i];
                GenetixFunction new2 = currentGeneration[rnd];
                new1.crossFunctions(new2, isArbitraryCrossings());
                newGeneration.add(new1);
                newGeneration.add(new2);
            }
        }
        setCurrentGeneration(newGeneration);
    }

    /**
     * This method crosses the functions of the actual generation. All the
     * functions might contribute to the new generation, the process is managed
     * using a crossing probability.
     */
    protected void reproductGeneration() {
        float prob = getReproductProbability();
        GenetixFunction.Tuple newGeneration = getCurrentGenerationAsTuple();
        final GenetixFunction[] currentGeneration = getCurrentGeneration();
        final int len = currentGeneration.length;
        for (int i = 0; i < len; i++) {
            if ( RandomHelper.randomBoolean(prob) ) {
                prob = getReproductProbability() * ((i + 1) / (len + 1));
                prob = getReproductProbability() - prob;
                newGeneration.add(currentGeneration[i]);
            }
        }
        setCurrentGeneration(newGeneration);
    }

    /**
     * This method adds (randomly generated) functions to the current
     * generation, the number of functions added is specified by the parameter.
     *
     * @param limit the size of the set of functions added to the current generation
     */
    protected void addNewToGeneration(int limit) {
        GenetixFunction.Tuple newGeneration = getCurrentGenerationAsTuple();
        newGeneration.addAll( generateFunctions(limit) );
        setCurrentGeneration(newGeneration);
    }

    /**
     * Sets the reproduction probability.
     */
    public void setReproductProbability(float prob) {
        this.reproductProbability = prob;
    }

    /**
     * Sets the reproduction probability.
     */
    public float getReproductProbability() {
        return reproductProbability;
    }

    /**
     * Sets the selection probability.
     */
    public void setSelectionProbability(float prob) {
        this.selectionProbability = prob;
    }

    /**
     * Sets the reproduction probability.
     */
    public float getSelectionProbability() {
        return selectionProbability;
    }

}


text:
package cz.jcu.uai.javapract;

import jdk.nashorn.internal.parser.JSONParser;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import org.json.*;

/**
 * Created by Drml on 4.7.2017.
 */
public class Parser {

    private Subject subject;
    private ArrayList<Subject> listOfSubject;

    /**
     * Parses string into TimeTable
     *
     * @param json
     * @return
     */
    public TimeTable parse(String json){
        //TODO: implement
        TimeTable rozvrh = new TimeTable(new Date(),splitJSON(json));
//        rozvrh.CreateTimeTable(new Date(),splitJSON(json));
        return rozvrh;
    }

    private ArrayList<Subject> splitJSON(String json){

        ArrayList<Subject> listOfSubject = new ArrayList<>();

        JSONArray vnejsiPole = new JSONArray(json);

        JSONObject vnejsiobj = (JSONObject) vnejsiPole.get(0);
        JSONArray rozvrhoveAkce = vnejsiobj.getJSONArray("rozvrhovaAkce");

        for(Object akce : rozvrhoveAkce){
            JSONObject jsonAkce = (JSONObject) akce;
            if (jsonAkce.isNull("roakIdno"))
                continue;
            else{
                JSONObject hodinaObj = jsonAkce.getJSONObject("hodinaSkutOd");
                String hodinaStart = hodinaObj.getString("value");
                JSONObject hodinaObj2 = jsonAkce.getJSONObject("hodinaSkutDo");
                String hodinaEnd = hodinaObj2.getString("value");

                String datumStart = null;
                String datumEnd = null;

                if (!jsonAkce.isNull("datumOd") || !jsonAkce.isNull("datumDo")) {
                    JSONObject datumObj = jsonAkce.getJSONObject("datumOd");
                    datumStart = datumObj.getString("value");
                    JSONObject datumObj2 = jsonAkce.getJSONObject("datumDo");
                    datumEnd = datumObj2.getString("value");
                }

                int day;
                if (jsonAkce.isNull("denZkr")){     // predmety bez rozvrhu
                    day = 0;
                } else {
                    switch(jsonAkce.getString("denZkr")) {
                        case "Po":
                            day = Calendar.MONDAY;
                            break;
                        case "Ut":
                            day = Calendar.TUESDAY;
                            break;
                        case "St":
                            day = Calendar.WEDNESDAY;
                            break;
                        case "Ct":
                            day = Calendar.THURSDAY;
                            break;
                        case "Pa":
                            day = Calendar.FRIDAY;
                            break;
                        default:
                            day = Calendar.SUNDAY;  //Error
                    }
                }

                //subject.ResetSubject();
                Boolean konase = false;
                if (jsonAkce.isNull("nekonaSe"))
                    konase = true;

                subject = new Subject(
                    jsonAkce.getString("typAkceZkr"),
                    jsonAkce.getString("nazev"),
                    jsonAkce.getInt("predmet"),
                    jsonAkce.getString("katedra"),
                    hodinaStart,
                    hodinaEnd,
                    day,
                        (jsonAkce.isNull("budova") ? null : jsonAkce.getString("budova")),
                        (jsonAkce.isNull("mistnost") ? null : jsonAkce.getString("mistnost")),
                    datumStart,
                    datumEnd,
                    konase
                );

                    listOfSubject.add(subject);
            }

        }

        return listOfSubject;

    }

}


text:
package gov.healthit.chpl.auth.json;

public class UserResetPasswordJSONObject {

	private String userName;
	private String email;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

}


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/genomics/v1/variants.proto

package com.google.genomics.v1;

/**
 * Protobuf type {@code google.genomics.v1.MergeVariantsRequest}
 */
public  final class MergeVariantsRequest extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.genomics.v1.MergeVariantsRequest)
    MergeVariantsRequestOrBuilder {
  // Use MergeVariantsRequest.newBuilder() to construct.
  private MergeVariantsRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private MergeVariantsRequest() {
    variantSetId_ = "";
    variants_ = java.util.Collections.emptyList();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
  }
  private MergeVariantsRequest(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    int mutable_bitField0_ = 0;
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          default: {
            if (!input.skipField(tag)) {
              done = true;
            }
            break;
          }
          case 10: {
            java.lang.String s = input.readStringRequireUtf8();

            variantSetId_ = s;
            break;
          }
          case 18: {
            if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
              variants_ = new java.util.ArrayList<com.google.genomics.v1.Variant>();
              mutable_bitField0_ |= 0x00000002;
            }
            variants_.add(
                input.readMessage(com.google.genomics.v1.Variant.parser(), extensionRegistry));
            break;
          }
          case 26: {
            if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
              infoMergeConfig_ = com.google.protobuf.MapField.newMapField(
                  InfoMergeConfigDefaultEntryHolder.defaultEntry);
              mutable_bitField0_ |= 0x00000004;
            }
            com.google.protobuf.MapEntry<java.lang.String, java.lang.Integer>
            infoMergeConfig__ = input.readMessage(
                InfoMergeConfigDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
            infoMergeConfig_.getMutableMap().put(
                infoMergeConfig__.getKey(), infoMergeConfig__.getValue());
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
        variants_ = java.util.Collections.unmodifiableList(variants_);
      }
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.genomics.v1.VariantsProto.internal_static_google_genomics_v1_MergeVariantsRequest_descriptor;
  }

  @SuppressWarnings({"rawtypes"})
  protected com.google.protobuf.MapField internalGetMapField(
      int number) {
    switch (number) {
      case 3:
        return internalGetInfoMergeConfig();
      default:
        throw new RuntimeException(
            "Invalid map field number: " + number);
    }
  }
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.genomics.v1.VariantsProto.internal_static_google_genomics_v1_MergeVariantsRequest_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.genomics.v1.MergeVariantsRequest.class, com.google.genomics.v1.MergeVariantsRequest.Builder.class);
  }

  private int bitField0_;
  public static final int VARIANT_SET_ID_FIELD_NUMBER = 1;
  private volatile java.lang.Object variantSetId_;
  /**
   *

   * The destination variant set.
   *

   *
   * optional string variant_set_id = 1;
   */
  public java.lang.String getVariantSetId() {
    java.lang.Object ref = variantSetId_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs =
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      variantSetId_ = s;
      return s;
    }
  }
  /**
   *

   * The destination variant set.
   *

   *
   * optional string variant_set_id = 1;
   */
  public com.google.protobuf.ByteString
      getVariantSetIdBytes() {
    java.lang.Object ref = variantSetId_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      variantSetId_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int VARIANTS_FIELD_NUMBER = 2;
  private java.util.List<com.google.genomics.v1.Variant> variants_;
  /**
   *

   * The variants to be merged with existing variants.
   *

   *
   * repeated .google.genomics.v1.Variant variants = 2;
   */
  public java.util.List<com.google.genomics.v1.Variant> getVariantsList() {
    return variants_;
  }
  /**
   *

   * The variants to be merged with existing variants.
   *

   *
   * repeated .google.genomics.v1.Variant variants = 2;
   */
  public java.util.List<? extends com.google.genomics.v1.VariantOrBuilder>
      getVariantsOrBuilderList() {
    return variants_;
  }
  /**
   *

   * The variants to be merged with existing variants.
   *

   *
   * repeated .google.genomics.v1.Variant variants = 2;
   */
  public int getVariantsCount() {
    return variants_.size();
  }
  /**
   *

   * The variants to be merged with existing variants.
   *

   *
   * repeated .google.genomics.v1.Variant variants = 2;
   */
  public com.google.genomics.v1.Variant getVariants(int index) {
    return variants_.get(index);
  }
  /**
   *

   * The variants to be merged with existing variants.
   *

   *
   * repeated .google.genomics.v1.Variant variants = 2;
   */
  public com.google.genomics.v1.VariantOrBuilder getVariantsOrBuilder(
      int index) {
    return variants_.get(index);
  }

  public static final int INFO_MERGE_CONFIG_FIELD_NUMBER = 3;
  private static final class InfoMergeConfigDefaultEntryHolder {
    static final com.google.protobuf.MapEntry<
        java.lang.String, java.lang.Integer> defaultEntry =
            com.google.protobuf.MapEntry
            .<java.lang.String, java.lang.Integer>newDefaultInstance(
                com.google.genomics.v1.VariantsProto.internal_static_google_genomics_v1_MergeVariantsRequest_InfoMergeConfigEntry_descriptor,
                com.google.protobuf.WireFormat.FieldType.STRING,
                "",
                com.google.protobuf.WireFormat.FieldType.ENUM,
                com.google.genomics.v1.InfoMergeOperation.INFO_MERGE_OPERATION_UNSPECIFIED.getNumber());
  }
  private com.google.protobuf.MapField<
      java.lang.String, java.lang.Integer> infoMergeConfig_;
  private com.google.protobuf.MapField<java.lang.String, java.lang.Integer>
  internalGetInfoMergeConfig() {
    if (infoMergeConfig_ == null) {
      return com.google.protobuf.MapField.emptyMapField(
          InfoMergeConfigDefaultEntryHolder.defaultEntry);
    }
    return infoMergeConfig_;
  }
  private static final
  com.google.protobuf.Internal.MapAdapter.Converter<
      java.lang.Integer, com.google.genomics.v1.InfoMergeOperation> infoMergeConfigValueConverter =
          com.google.protobuf.Internal.MapAdapter.newEnumConverter(
              com.google.genomics.v1.InfoMergeOperation.internalGetValueMap(),
              com.google.genomics.v1.InfoMergeOperation.UNRECOGNIZED);

  public int getInfoMergeConfigCount() {
    return internalGetInfoMergeConfig().getMap().size();
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public boolean containsInfoMergeConfig(
      java.lang.String key) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    return internalGetInfoMergeConfig().getMap().containsKey(key);
  }
  /**
   * Use {@link #getInfoMergeConfigMap()} instead.
   */
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, com.google.genomics.v1.InfoMergeOperation>
  getInfoMergeConfig() {
    return getInfoMergeConfigMap();
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public java.util.Map<java.lang.String, com.google.genomics.v1.InfoMergeOperation>
  getInfoMergeConfigMap() {
    return new com.google.protobuf.Internal.MapAdapter<
        java.lang.String, com.google.genomics.v1.InfoMergeOperation, java.lang.Integer>(
            internalGetInfoMergeConfig().getMap(),
            infoMergeConfigValueConverter);
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public com.google.genomics.v1.InfoMergeOperation getInfoMergeConfigOrDefault(
      java.lang.String key,
      com.google.genomics.v1.InfoMergeOperation defaultValue) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.Integer> map =
        internalGetInfoMergeConfig().getMap();
    return map.containsKey(key)
           ? infoMergeConfigValueConverter.doForward(map.get(key))
           : defaultValue;
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public com.google.genomics.v1.InfoMergeOperation getInfoMergeConfigOrThrow(
      java.lang.String key) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.Integer> map =
        internalGetInfoMergeConfig().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return infoMergeConfigValueConverter.doForward(map.get(key));
  }
  /**
   * Use {@link #getInfoMergeConfigValueMap()} instead.
   */
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.Integer>
  getInfoMergeConfigValue() {
    return getInfoMergeConfigValueMap();
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public java.util.Map<java.lang.String, java.lang.Integer>
  getInfoMergeConfigValueMap() {
    return internalGetInfoMergeConfig().getMap();
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public int getInfoMergeConfigValueOrDefault(
      java.lang.String key,
      int defaultValue) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.Integer> map =
        internalGetInfoMergeConfig().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
  /**
   *

   * A mapping between info field keys and the InfoMergeOperations to
   * be performed on them.
   *

   *
   * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
   */

  public int getInfoMergeConfigValueOrThrow(
      java.lang.String key) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.Integer> map =
        internalGetInfoMergeConfig().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    if (!getVariantSetIdBytes().isEmpty()) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, variantSetId_);
    }
    for (int i = 0; i < variants_.size(); i++) {
      output.writeMessage(2, variants_.get(i));
    }
    com.google.protobuf.GeneratedMessageV3
      .serializeStringMapTo(
        output,
        internalGetInfoMergeConfig(),
        InfoMergeConfigDefaultEntryHolder.defaultEntry,
        3);
  }

  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!getVariantSetIdBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, variantSetId_);
    }
    for (int i = 0; i < variants_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(2, variants_.get(i));
    }
    for (java.util.Map.Entry<java.lang.String, java.lang.Integer> entry
         : internalGetInfoMergeConfig().getMap().entrySet()) {
      com.google.protobuf.MapEntry<java.lang.String, java.lang.Integer>
      infoMergeConfig__ = InfoMergeConfigDefaultEntryHolder.defaultEntry.newBuilderForType()
          .setKey(entry.getKey())
          .setValue(entry.getValue())
          .build();
      size += com.google.protobuf.CodedOutputStream
          .computeMessageSize(3, infoMergeConfig__);
    }
    memoizedSize = size;
    return size;
  }

  private static final long serialVersionUID = 0L;
  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.google.genomics.v1.MergeVariantsRequest)) {
      return super.equals(obj);
    }
    com.google.genomics.v1.MergeVariantsRequest other = (com.google.genomics.v1.MergeVariantsRequest) obj;

    boolean result = true;
    result = result && getVariantSetId()
        .equals(other.getVariantSetId());
    result = result && getVariantsList()
        .equals(other.getVariantsList());
    result = result && internalGetInfoMergeConfig().equals(
        other.internalGetInfoMergeConfig());
    return result;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptorForType().hashCode();
    hash = (37 * hash) + VARIANT_SET_ID_FIELD_NUMBER;
    hash = (53 * hash) + getVariantSetId().hashCode();
    if (getVariantsCount() > 0) {
      hash = (37 * hash) + VARIANTS_FIELD_NUMBER;
      hash = (53 * hash) + getVariantsList().hashCode();
    }
    if (!internalGetInfoMergeConfig().getMap().isEmpty()) {
      hash = (37 * hash) + INFO_MERGE_CONFIG_FIELD_NUMBER;
      hash = (53 * hash) + internalGetInfoMergeConfig().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.genomics.v1.MergeVariantsRequest parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(com.google.genomics.v1.MergeVariantsRequest prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   * Protobuf type {@code google.genomics.v1.MergeVariantsRequest}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.genomics.v1.MergeVariantsRequest)
      com.google.genomics.v1.MergeVariantsRequestOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.genomics.v1.VariantsProto.internal_static_google_genomics_v1_MergeVariantsRequest_descriptor;
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMapField(
        int number) {
      switch (number) {
        case 3:
          return internalGetInfoMergeConfig();
        default:
          throw new RuntimeException(
              "Invalid map field number: " + number);
      }
    }
    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMutableMapField(
        int number) {
      switch (number) {
        case 3:
          return internalGetMutableInfoMergeConfig();
        default:
          throw new RuntimeException(
              "Invalid map field number: " + number);
      }
    }
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.genomics.v1.VariantsProto.internal_static_google_genomics_v1_MergeVariantsRequest_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.genomics.v1.MergeVariantsRequest.class, com.google.genomics.v1.MergeVariantsRequest.Builder.class);
    }

    // Construct using com.google.genomics.v1.MergeVariantsRequest.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
        getVariantsFieldBuilder();
      }
    }
    public Builder clear() {
      super.clear();
      variantSetId_ = "";

      if (variantsBuilder_ == null) {
        variants_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
      } else {
        variantsBuilder_.clear();
      }
      internalGetMutableInfoMergeConfig().clear();
      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.genomics.v1.VariantsProto.internal_static_google_genomics_v1_MergeVariantsRequest_descriptor;
    }

    public com.google.genomics.v1.MergeVariantsRequest getDefaultInstanceForType() {
      return com.google.genomics.v1.MergeVariantsRequest.getDefaultInstance();
    }

    public com.google.genomics.v1.MergeVariantsRequest build() {
      com.google.genomics.v1.MergeVariantsRequest result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public com.google.genomics.v1.MergeVariantsRequest buildPartial() {
      com.google.genomics.v1.MergeVariantsRequest result = new com.google.genomics.v1.MergeVariantsRequest(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      result.variantSetId_ = variantSetId_;
      if (variantsBuilder_ == null) {
        if (((bitField0_ & 0x00000002) == 0x00000002)) {
          variants_ = java.util.Collections.unmodifiableList(variants_);
          bitField0_ = (bitField0_ & ~0x00000002);
        }
        result.variants_ = variants_;
      } else {
        result.variants_ = variantsBuilder_.build();
      }
      result.infoMergeConfig_ = internalGetInfoMergeConfig();
      result.infoMergeConfig_.makeImmutable();
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    public Builder clone() {
      return (Builder) super.clone();
    }
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        Object value) {
      return (Builder) super.setField(field, value);
    }
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return (Builder) super.clearField(field);
    }
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return (Builder) super.clearOneof(oneof);
    }
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, Object value) {
      return (Builder) super.setRepeatedField(field, index, value);
    }
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        Object value) {
      return (Builder) super.addRepeatedField(field, value);
    }
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.genomics.v1.MergeVariantsRequest) {
        return mergeFrom((com.google.genomics.v1.MergeVariantsRequest)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.genomics.v1.MergeVariantsRequest other) {
      if (other == com.google.genomics.v1.MergeVariantsRequest.getDefaultInstance()) return this;
      if (!other.getVariantSetId().isEmpty()) {
        variantSetId_ = other.variantSetId_;
        onChanged();
      }
      if (variantsBuilder_ == null) {
        if (!other.variants_.isEmpty()) {
          if (variants_.isEmpty()) {
            variants_ = other.variants_;
            bitField0_ = (bitField0_ & ~0x00000002);
          } else {
            ensureVariantsIsMutable();
            variants_.addAll(other.variants_);
          }
          onChanged();
        }
      } else {
        if (!other.variants_.isEmpty()) {
          if (variantsBuilder_.isEmpty()) {
            variantsBuilder_.dispose();
            variantsBuilder_ = null;
            variants_ = other.variants_;
            bitField0_ = (bitField0_ & ~0x00000002);
            variantsBuilder_ =
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getVariantsFieldBuilder() : null;
          } else {
            variantsBuilder_.addAllMessages(other.variants_);
          }
        }
      }
      internalGetMutableInfoMergeConfig().mergeFrom(
          other.internalGetInfoMergeConfig());
      onChanged();
      return this;
    }

    public final boolean isInitialized() {
      return true;
    }

    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      com.google.genomics.v1.MergeVariantsRequest parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.genomics.v1.MergeVariantsRequest) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int bitField0_;

    private java.lang.Object variantSetId_ = "";
    /**
     *

     * The destination variant set.
     *

     *
     * optional string variant_set_id = 1;
     */
    public java.lang.String getVariantSetId() {
      java.lang.Object ref = variantSetId_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        variantSetId_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *

     * The destination variant set.
     *

     *
     * optional string variant_set_id = 1;
     */
    public com.google.protobuf.ByteString
        getVariantSetIdBytes() {
      java.lang.Object ref = variantSetId_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        variantSetId_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *

     * The destination variant set.
     *

     *
     * optional string variant_set_id = 1;
     */
    public Builder setVariantSetId(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }

      variantSetId_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * The destination variant set.
     *

     *
     * optional string variant_set_id = 1;
     */
    public Builder clearVariantSetId() {

      variantSetId_ = getDefaultInstance().getVariantSetId();
      onChanged();
      return this;
    }
    /**
     *

     * The destination variant set.
     *

     *
     * optional string variant_set_id = 1;
     */
    public Builder setVariantSetIdBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);

      variantSetId_ = value;
      onChanged();
      return this;
    }

    private java.util.List<com.google.genomics.v1.Variant> variants_ =
      java.util.Collections.emptyList();
    private void ensureVariantsIsMutable() {
      if (!((bitField0_ & 0x00000002) == 0x00000002)) {
        variants_ = new java.util.ArrayList<com.google.genomics.v1.Variant>(variants_);
        bitField0_ |= 0x00000002;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.genomics.v1.Variant, com.google.genomics.v1.Variant.Builder, com.google.genomics.v1.VariantOrBuilder> variantsBuilder_;

    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public java.util.List<com.google.genomics.v1.Variant> getVariantsList() {
      if (variantsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(variants_);
      } else {
        return variantsBuilder_.getMessageList();
      }
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public int getVariantsCount() {
      if (variantsBuilder_ == null) {
        return variants_.size();
      } else {
        return variantsBuilder_.getCount();
      }
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public com.google.genomics.v1.Variant getVariants(int index) {
      if (variantsBuilder_ == null) {
        return variants_.get(index);
      } else {
        return variantsBuilder_.getMessage(index);
      }
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder setVariants(
        int index, com.google.genomics.v1.Variant value) {
      if (variantsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureVariantsIsMutable();
        variants_.set(index, value);
        onChanged();
      } else {
        variantsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder setVariants(
        int index, com.google.genomics.v1.Variant.Builder builderForValue) {
      if (variantsBuilder_ == null) {
        ensureVariantsIsMutable();
        variants_.set(index, builderForValue.build());
        onChanged();
      } else {
        variantsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder addVariants(com.google.genomics.v1.Variant value) {
      if (variantsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureVariantsIsMutable();
        variants_.add(value);
        onChanged();
      } else {
        variantsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder addVariants(
        int index, com.google.genomics.v1.Variant value) {
      if (variantsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureVariantsIsMutable();
        variants_.add(index, value);
        onChanged();
      } else {
        variantsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder addVariants(
        com.google.genomics.v1.Variant.Builder builderForValue) {
      if (variantsBuilder_ == null) {
        ensureVariantsIsMutable();
        variants_.add(builderForValue.build());
        onChanged();
      } else {
        variantsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder addVariants(
        int index, com.google.genomics.v1.Variant.Builder builderForValue) {
      if (variantsBuilder_ == null) {
        ensureVariantsIsMutable();
        variants_.add(index, builderForValue.build());
        onChanged();
      } else {
        variantsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder addAllVariants(
        java.lang.Iterable<? extends com.google.genomics.v1.Variant> values) {
      if (variantsBuilder_ == null) {
        ensureVariantsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, variants_);
        onChanged();
      } else {
        variantsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder clearVariants() {
      if (variantsBuilder_ == null) {
        variants_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
        onChanged();
      } else {
        variantsBuilder_.clear();
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public Builder removeVariants(int index) {
      if (variantsBuilder_ == null) {
        ensureVariantsIsMutable();
        variants_.remove(index);
        onChanged();
      } else {
        variantsBuilder_.remove(index);
      }
      return this;
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public com.google.genomics.v1.Variant.Builder getVariantsBuilder(
        int index) {
      return getVariantsFieldBuilder().getBuilder(index);
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public com.google.genomics.v1.VariantOrBuilder getVariantsOrBuilder(
        int index) {
      if (variantsBuilder_ == null) {
        return variants_.get(index);  } else {
        return variantsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public java.util.List<? extends com.google.genomics.v1.VariantOrBuilder>
         getVariantsOrBuilderList() {
      if (variantsBuilder_ != null) {
        return variantsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(variants_);
      }
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public com.google.genomics.v1.Variant.Builder addVariantsBuilder() {
      return getVariantsFieldBuilder().addBuilder(
          com.google.genomics.v1.Variant.getDefaultInstance());
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public com.google.genomics.v1.Variant.Builder addVariantsBuilder(
        int index) {
      return getVariantsFieldBuilder().addBuilder(
          index, com.google.genomics.v1.Variant.getDefaultInstance());
    }
    /**
     *

     * The variants to be merged with existing variants.
     *

     *
     * repeated .google.genomics.v1.Variant variants = 2;
     */
    public java.util.List<com.google.genomics.v1.Variant.Builder>
         getVariantsBuilderList() {
      return getVariantsFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.genomics.v1.Variant, com.google.genomics.v1.Variant.Builder, com.google.genomics.v1.VariantOrBuilder>
        getVariantsFieldBuilder() {
      if (variantsBuilder_ == null) {
        variantsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.genomics.v1.Variant, com.google.genomics.v1.Variant.Builder, com.google.genomics.v1.VariantOrBuilder>(
                variants_,
                ((bitField0_ & 0x00000002) == 0x00000002),
                getParentForChildren(),
                isClean());
        variants_ = null;
      }
      return variantsBuilder_;
    }

    private com.google.protobuf.MapField<
        java.lang.String, java.lang.Integer> infoMergeConfig_;
    private com.google.protobuf.MapField<java.lang.String, java.lang.Integer>
    internalGetInfoMergeConfig() {
      if (infoMergeConfig_ == null) {
        return com.google.protobuf.MapField.emptyMapField(
            InfoMergeConfigDefaultEntryHolder.defaultEntry);
      }
      return infoMergeConfig_;
    }
    private com.google.protobuf.MapField<java.lang.String, java.lang.Integer>
    internalGetMutableInfoMergeConfig() {
      onChanged();;
      if (infoMergeConfig_ == null) {
        infoMergeConfig_ = com.google.protobuf.MapField.newMapField(
            InfoMergeConfigDefaultEntryHolder.defaultEntry);
      }
      if (!infoMergeConfig_.isMutable()) {
        infoMergeConfig_ = infoMergeConfig_.copy();
      }
      return infoMergeConfig_;
    }

    public int getInfoMergeConfigCount() {
      return internalGetInfoMergeConfig().getMap().size();
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public boolean containsInfoMergeConfig(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      return internalGetInfoMergeConfig().getMap().containsKey(key);
    }
    /**
     * Use {@link #getInfoMergeConfigMap()} instead.
     */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, com.google.genomics.v1.InfoMergeOperation>
    getInfoMergeConfig() {
      return getInfoMergeConfigMap();
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public java.util.Map<java.lang.String, com.google.genomics.v1.InfoMergeOperation>
    getInfoMergeConfigMap() {
      return new com.google.protobuf.Internal.MapAdapter<
          java.lang.String, com.google.genomics.v1.InfoMergeOperation, java.lang.Integer>(
              internalGetInfoMergeConfig().getMap(),
              infoMergeConfigValueConverter);
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public com.google.genomics.v1.InfoMergeOperation getInfoMergeConfigOrDefault(
        java.lang.String key,
        com.google.genomics.v1.InfoMergeOperation defaultValue) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      java.util.Map<java.lang.String, java.lang.Integer> map =
          internalGetInfoMergeConfig().getMap();
      return map.containsKey(key)
             ? infoMergeConfigValueConverter.doForward(map.get(key))
             : defaultValue;
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public com.google.genomics.v1.InfoMergeOperation getInfoMergeConfigOrThrow(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      java.util.Map<java.lang.String, java.lang.Integer> map =
          internalGetInfoMergeConfig().getMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return infoMergeConfigValueConverter.doForward(map.get(key));
    }
    /**
     * Use {@link #getInfoMergeConfigValueMap()} instead.
     */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.Integer>
    getInfoMergeConfigValue() {
      return getInfoMergeConfigValueMap();
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public java.util.Map<java.lang.String, java.lang.Integer>
    getInfoMergeConfigValueMap() {
      return internalGetInfoMergeConfig().getMap();
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public int getInfoMergeConfigValueOrDefault(
        java.lang.String key,
        int defaultValue) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      java.util.Map<java.lang.String, java.lang.Integer> map =
          internalGetInfoMergeConfig().getMap();
      return map.containsKey(key) ? map.get(key) : defaultValue;
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public int getInfoMergeConfigValueOrThrow(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      java.util.Map<java.lang.String, java.lang.Integer> map =
          internalGetInfoMergeConfig().getMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return map.get(key);
    }

    public Builder clearInfoMergeConfig() {
      getMutableInfoMergeConfig().clear();
      return this;
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */

    public Builder removeInfoMergeConfig(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      getMutableInfoMergeConfig().remove(key);
      return this;
    }
    /**
     * Use alternate mutation accessors instead.
     */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, com.google.genomics.v1.InfoMergeOperation>
    getMutableInfoMergeConfig() {
      return new com.google.protobuf.Internal.MapAdapter<
          java.lang.String, com.google.genomics.v1.InfoMergeOperation, java.lang.Integer>(
              internalGetMutableInfoMergeConfig().getMutableMap(),
              infoMergeConfigValueConverter);
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */
    public Builder putInfoMergeConfig(
        java.lang.String key,
        com.google.genomics.v1.InfoMergeOperation value) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      if (value == null) { throw new java.lang.NullPointerException(); }
      getMutableInfoMergeConfig().put(key, value);
      return this;
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */
    public Builder putAllInfoMergeConfig(
        java.util.Map<java.lang.String, com.google.genomics.v1.InfoMergeOperation> values) {
      getMutableInfoMergeConfig().putAll(values);
      return this;
    }
    /**
     * Use alternate mutation accessors instead.
     */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.Integer>
    getMutableInfoMergeConfigValue() {
      return internalGetMutableInfoMergeConfig().getMutableMap();
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */
    public Builder putInfoMergeConfigValue(
        java.lang.String key,
        int value) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      if (com.google.genomics.v1.InfoMergeOperation.forNumber(value) == null) {
        throw new java.lang.IllegalArgumentException();
      }
      getMutableInfoMergeConfigValue().put(key, value);
      return this;
    }
    /**
     *

     * A mapping between info field keys and the InfoMergeOperations to
     * be performed on them.
     *

     *
     * map<string, .google.genomics.v1.InfoMergeOperation> info_merge_config = 3;
     */
    public Builder putAllInfoMergeConfigValue(
        java.util.Map<java.lang.String, java.lang.Integer> values) {
      getMutableInfoMergeConfigValue().putAll(values);
      return this;
    }
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    // @@protoc_insertion_point(builder_scope:google.genomics.v1.MergeVariantsRequest)
  }

  // @@protoc_insertion_point(class_scope:google.genomics.v1.MergeVariantsRequest)
  private static final com.google.genomics.v1.MergeVariantsRequest DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.genomics.v1.MergeVariantsRequest();
  }

  public static com.google.genomics.v1.MergeVariantsRequest getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<MergeVariantsRequest>
      PARSER = new com.google.protobuf.AbstractParser<MergeVariantsRequest>() {
    public MergeVariantsRequest parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return new MergeVariantsRequest(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<MergeVariantsRequest> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<MergeVariantsRequest> getParserForType() {
    return PARSER;
  }

  public com.google.genomics.v1.MergeVariantsRequest getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}