code: private void setVertex(Geometry geom, GeometryIndex index, Coordinate coordinate)
  			throws GeometryIndexNotFoundException {
  		if (index.hasChild() && geom.getGeometries() != null && geom.getGeometries().length > index.getValue()) {
  			setVertex(geom.getGeometries()[index.getValue()], index.getChild(), coordinate);
  		} else if (index.getType() == GeometryIndexType.TYPE_VERTEX && geom.getCoordinates() != null
  				&& geom.getCoordinates().length > index.getValue()) {
  			if (geom.getGeometryType().equals(Geometry.LINEAR_RING)) {
  				// In case of a closed ring, the last vertex is not allowed to be moved:
  				if ((geom.getCoordinates().length - 1) > index.getValue()) {
  					geom.getCoordinates()[index.getValue()] = coordinate;
  					if (index.getValue() == 0) {
  						// In case of closed ring, keep last coordinate equal to the first:
  						geom.getCoordinates()[geom.getCoordinates().length - 1] = new Coordinate(coordinate);
  					}
  				} else {
  					throw new GeometryIndexNotFoundException("Can't move closing vertex of a LinearRing, "
  							+ "move index=0 instead.");
  				}
  			} else {
  				geom.getCoordinates()[index.getValue()] = coordinate;
  			}
  		} else {
  			throw new GeometryIndexNotFoundException("Could not match index with given geometry");
  		}
  	}
docs: ------------------------------------------------------------------------