text:
namespace {}

namespace device {

FakeArCore::FakeArCore()
    : gl_thread_task_runner_(
          base::SingleThreadTaskRunner::GetCurrentDefault()) {}

FakeArCore::~FakeArCore() = default;

ArCore::MinMaxRange FakeArCore::GetTargetFramerateRange() {
  return {30.f, 30.f};
}

absl::optional<ArCore::InitializeResult> FakeArCore::Initialize(
    base::android::ScopedJavaLocalRef<jobject> application_context,
    const std::unordered_set<device::mojom::XRSessionFeature>&
        required_features,
    const std::unordered_set<device::mojom::XRSessionFeature>&
        optional_features,
    const std::vector<device::mojom::XRTrackedImagePtr>& tracked_images,
    absl::optional<ArCore::DepthSensingConfiguration> depth_sensing_config) {
  DCHECK(IsOnGlThread());

  std::unordered_set<device::mojom::XRSessionFeature> enabled_features;
  enabled_features.insert(required_features.begin(), required_features.end());
  enabled_features.insert(optional_features.begin(), optional_features.end());

  // Fake device does not support depth for now:
  if (base::Contains(required_features,
                     device::mojom::XRSessionFeature::DEPTH)) {
    return absl::nullopt;
  }

  if (base::Contains(optional_features,
                     device::mojom::XRSessionFeature::DEPTH)) {
    enabled_features.erase(device::mojom::XRSessionFeature::DEPTH);
  }

  return ArCore::InitializeResult(enabled_features, absl::nullopt);
}

void FakeArCore::SetDisplayGeometry(
    const gfx::Size& frame_size,
    display::Display::Rotation display_rotation) {
  DCHECK(IsOnGlThread());

  display_rotation_ = display_rotation;
  frame_size_ = frame_size;
}

gfx::Size FakeArCore::GetUncroppedCameraImageSize() const {
  return {1920, 960};
}

void FakeArCore::SetCameraTexture(uint32_t texture) {
  DCHECK(IsOnGlThread());
  // This is a no-op for the FakeArCore implementation. We might want to
  // store the textureid for use in unit tests, but currently ArCoreDeviceTest
  // is using mocked image transport so the actual texture doesn't have to
  // be set. Current approach won't work for tests that rely on the texture.

  DVLOG(2) << __FUNCTION__ << ": camera texture=" << texture;
}

std::vector<float> FakeArCore::TransformDisplayUvCoords(
    const base::span<const float> uvs) const {
  // Try to match ArCore's transform values.
  //
  // Sample ArCore input: width=1080, height=1795, rotation=0,
  // vecs = (0, 0), (0, 1), (1, 0), (1, 1)
  // Sample ArCore output:
  //   (0.0325544, 1,
  //    0.967446, 1,
  //    0.0325543, 0,
  //    0.967446, 1.19209e-07)
  //
  // FakeArCoreDriver test_arcore;
  // test_arcore.SetCameraAspect(16.f / 9.f);
  // test_arcore.SetDisplayGeometry(0, 1080, 1795);
  // float in[8] = {0, 0, 0, 1, 1, 0, 1, 1};
  // float out[8];
  // test_arcore.TransformDisplayUvCoords(8, &in[0], &out[0]);
  //
  // Fake driver result:
  // TransformDisplayUvCoords: too wide. v0=0.0325521 vrange=0.934896
  //    uv[0]=(0.0325521, 1)
  //    uv[2]=(0.967448, 1)
  //    uv[4]=(0.0325521, 0)
  //    uv[6]=(0.967448, 0)
  //
  // TODO(https://crbug.com/1382576): This logic is quite complicated,
  // and the current arcore_device_unittest doesn't really care about
  // the details.

  // SetDisplayGeometry should have been called first.
  DCHECK(frame_size_.width());
  DCHECK(frame_size_.height());

  DCHECK_GE(uvs.size(), 6u);

  // Do clipping calculations in orientation ROTATE_0. screen U is left=0,
  // right=1. Screen V is bottom=0, top=1. We'll apply screen rotation later.

  float display_aspect =
      static_cast<float>(frame_size_.width()) / frame_size_.height();
  float target_aspect = camera_aspect_;

  // Simulate that the fake camera is rotated by 90 degrees from the usual
  // convention to match the Pixel camera. If the screen is in portrait mode
  // (ROTATION_0), the camera's UV origin is around the bottom right of the
  // screen, with camera +u going left and camera +v going up on the screen. So
  // use the original camera aspect in landscape/seascape, and the inverse
  // for portrait/upside-down orientation.
  if (display_rotation_ == display::Display::Rotation::ROTATE_0 ||
      display_rotation_ == display::Display::Rotation::ROTATE_180) {
    target_aspect = 1.0f / target_aspect;
  }
  DVLOG(3) << __FUNCTION__ << ": rotation=" << display_rotation_
           << " frame_size_.width=" << frame_size_.width()
           << " frame_size_.height=" << frame_size_.height()
           << " display_aspect=" << display_aspect
           << " target_aspect=" << target_aspect;

  float u0 = 0;
  float v0 = 0;
  float urange = 1;
  float vrange = 1;

  if (display_aspect > target_aspect) {
    // Display too wide. Fill width, crop V evenly at top/bottom.
    vrange = target_aspect / display_aspect;
    v0 = (1.f - vrange) / 2;
    DVLOG(3) << ": too wide. v0=" << v0 << " vrange=" << vrange;
  } else {
    // Display too narrow. Fill height, crop U evenly at sides.
    urange = display_aspect / target_aspect;
    u0 = (1.f - urange) / 2;
    DVLOG(3) << ": too narrow. u0=" << u0 << " urange=" << urange;
  }

  size_t num_elements = uvs.size();
  DCHECK(num_elements % 2 == 0);
  std::vector<float> uvs_out;
  uvs_out.reserve(num_elements);
  for (size_t i = 0; i < num_elements; i += 2) {
    float x = uvs[i];
    float y = uvs[i + 1];
    float u, v;
    switch (display_rotation_) {
      case display::Display::Rotation::ROTATE_90:
        u = u0 + x * urange;
        v = v0 + y * vrange;
        break;
      case display::Display::Rotation::ROTATE_180:
        u = 1.f - (v0 + y * vrange);
        v = u0 + x * urange;
        break;
      case display::Display::Rotation::ROTATE_270:
        u = 1.f - (u0 + x * urange);
        v = 1.f - (v0 + y * vrange);
        break;
      case display::Display::Rotation::ROTATE_0:
        u = v0 + y * vrange;
        v = 1.f - (u0 + x * urange);
        break;
    }
    uvs_out.push_back(u);
    uvs_out.push_back(v);
    DVLOG(2) << __FUNCTION__ << ": uv[" << i << "]=(" << u << ", " << v << ")";
  }

  return uvs_out;
}

gfx::Transform FakeArCore::GetProjectionMatrix(float near, float far) {
  DCHECK(IsOnGlThread());
  // Get a projection matrix matching the current screen orientation and
  // aspect. Currently, this uses a hardcoded FOV angle for the smaller screen
  // dimension, and adjusts the other angle to preserve the aspect. A better
  // simulation of ArCore should apply cropping to the underlying fixed-aspect
  // simulated camera image.
  constexpr float fov_half_angle_degrees = 30.f;
  float base_tan = tanf(fov_half_angle_degrees * base::kPiFloat / 180.f);
  float right_tan;
  float up_tan;
  if (display_rotation_ == display::Display::Rotation::ROTATE_0 ||
      display_rotation_ == display::Display::Rotation::ROTATE_180) {
    // portrait aspect
    right_tan = base_tan;
    up_tan = base_tan * frame_size_.height() / frame_size_.width();
  } else {
    // landscape aspect
    up_tan = base_tan;
    right_tan = base_tan * frame_size_.width() / frame_size_.height();
  }
  // Calculate a perspective matrix based on the FOV values.
  gfx::Transform result;
  result.set_rc(0, 0, 1.f / right_tan);
  result.set_rc(1, 1, 1.f / up_tan);
  result.set_rc(2, 2, (near + far) / (near - far));
  result.set_rc(3, 2, -1.0f);
  result.set_rc(2, 3, (2.0f * far * near) / (near - far));
  result.set_rc(3, 3, 0.0f);
  return result;
}

mojom::VRPosePtr FakeArCore::Update(bool* camera_updated) {
  DCHECK(IsOnGlThread());
  DCHECK(camera_updated);

  *camera_updated = true;

  // 1m up from the origin, neutral orientation facing forward.
  mojom::VRPosePtr pose = mojom::VRPose::New();
  pose->position = gfx::Point3F(0.0, 1.0, 0.0);
  pose->orientation = gfx::Quaternion();

  return pose;
}

base::TimeDelta FakeArCore::GetFrameTimestamp() {
  return base::TimeTicks::Now() - base::TimeTicks();
}

float FakeArCore::GetEstimatedFloorHeight() {
  return 2.0;
}

bool FakeArCore::RequestHitTest(
    const mojom::XRRayPtr& ray,
    std::vector<mojom::XRHitResultPtr>* hit_results) {
  mojom::XRHitResultPtr hit = mojom::XRHitResult::New();
  // Default-constructed `hit->mojo_from_result` is fine, no need to set
  // anything.
  hit_results->push_back(std::move(hit));

  return true;
}

absl::optional<uint64_t> FakeArCore::SubscribeToHitTest(
    mojom::XRNativeOriginInformationPtr nativeOriginInformation,
    const std::vector<mojom::EntityTypeForHitTest>& entity_types,
    mojom::XRRayPtr ray) {
  NOTREACHED();
  return absl::nullopt;
}

absl::optional<uint64_t> FakeArCore::SubscribeToHitTestForTransientInput(
    const std::string& profile_name,
    const std::vector<mojom::EntityTypeForHitTest>& entity_types,
    mojom::XRRayPtr ray) {
  NOTREACHED();
  return absl::nullopt;
}

mojom::XRHitTestSubscriptionResultsDataPtr
FakeArCore::GetHitTestSubscriptionResults(
    const gfx::Transform& mojo_from_viewer,
    const std::vector<mojom::XRInputSourceStatePtr>& input_state) {
  return nullptr;
}

void FakeArCore::UnsubscribeFromHitTest(uint64_t subscription_id) {
  NOTREACHED();
}

mojom::XRPlaneDetectionDataPtr FakeArCore::GetDetectedPlanesData() {
  std::vector<mojom::XRPlaneDataPtr> result;

  // 1m ahead of the origin, neutral orientation facing forward.
  device::Pose pose(gfx::Point3F(0.0, 0.0, -1.0), gfx::Quaternion());

  // some random triangle
  std::vector<mojom::XRPlanePointDataPtr> vertices;
  vertices.push_back(mojom::XRPlanePointData::New(-0.3, -0.3));
  vertices.push_back(mojom::XRPlanePointData::New(0, 0.3));
  vertices.push_back(mojom::XRPlanePointData::New(0.3, -0.3));

  result.push_back(
      mojom::XRPlaneData::New(1, device::mojom::XRPlaneOrientation::HORIZONTAL,
                              pose, std::move(vertices)));

  return mojom::XRPlaneDetectionData::New(std::vector<uint64_t>{1},
                                          std::move(result));
}

mojom::XRAnchorsDataPtr FakeArCore::GetAnchorsData() {
  std::vector<mojom::XRAnchorDataPtr> result;
  std::vector<uint64_t> result_ids;

  for (auto& anchor_id_and_data : anchors_) {
    device::Pose pose(anchor_id_and_data.second.position,
                      anchor_id_and_data.second.orientation);

    result.push_back(mojom::XRAnchorData::New(anchor_id_and_data.first, pose));
    result_ids.push_back(anchor_id_and_data.first);
  }

  return mojom::XRAnchorsData::New(std::move(result_ids), std::move(result));
}

mojom::XRLightEstimationDataPtr FakeArCore::GetLightEstimationData() {
  auto result = mojom::XRLightEstimationData::New();

  // Initialize light probe with a top-down white light
  result->light_probe = mojom::XRLightProbe::New();
  result->light_probe->main_light_direction = gfx::Vector3dF(0, -1, 0);
  result->light_probe->main_light_intensity = device::RgbTupleF32(1, 1, 1);

  // Initialize spherical harmonics to zero-filled array
  result->light_probe->spherical_harmonics = mojom::XRSphericalHarmonics::New();
  result->light_probe->spherical_harmonics->coefficients.resize(9);

  // Initialize reflection_probe to black
  result->reflection_probe = mojom::XRReflectionProbe::New();
  result->reflection_probe->cube_map = mojom::XRCubeMap::New();
  result->reflection_probe->cube_map->width_and_height = 16;
  result->reflection_probe->cube_map->positive_x.resize(16 * 16);
  result->reflection_probe->cube_map->negative_x.resize(16 * 16);
  result->reflection_probe->cube_map->positive_y.resize(16 * 16);
  result->reflection_probe->cube_map->negative_y.resize(16 * 16);
  result->reflection_probe->cube_map->positive_z.resize(16 * 16);
  result->reflection_probe->cube_map->negative_z.resize(16 * 16);

  return result;
}

mojom::XRDepthDataPtr FakeArCore::GetDepthData() {
  return nullptr;
}

void FakeArCore::CreatePlaneAttachedAnchor(
    const mojom::XRNativeOriginInformation& native_origin_information,
    const device::Pose& native_origin_from_anchor,
    uint64_t plane_id,
    CreateAnchorCallback callback) {
  // TODO(992035): Fix this when implementing tests.
  std::move(callback).Run(mojom::CreateAnchorResult::FAILURE, 0);
}

void FakeArCore::CreateAnchor(
    const mojom::XRNativeOriginInformation& native_origin_information,
    const device::Pose& native_origin_from_anchor,
    CreateAnchorCallback callback) {
  std::move(callback).Run(mojom::CreateAnchorResult::FAILURE, 0);
}

void FakeArCore::ProcessAnchorCreationRequests(
    const gfx::Transform& mojo_from_viewer,
    const std::vector<mojom::XRInputSourceStatePtr>& input_state,
    const base::TimeTicks& frame_time) {
  // No-op - nothing gets deferred so far.
}

void FakeArCore::DetachAnchor(uint64_t anchor_id) {
  auto count = anchors_.erase(anchor_id);
  DCHECK_EQ(1u, count);
}

mojom::XRTrackedImagesDataPtr FakeArCore::GetTrackedImages() {
  std::vector<mojom::XRTrackedImageDataPtr> images_data;
  return mojom::XRTrackedImagesData::New(std::move(images_data), absl::nullopt);
}

void FakeArCore::Pause() {
  DCHECK(IsOnGlThread());
}

void FakeArCore::Resume() {
  DCHECK(IsOnGlThread());
}

bool FakeArCore::IsOnGlThread() const {
  return gl_thread_task_runner_->BelongsToCurrentThread();
}

std::unique_ptr<ArCore> FakeArCoreFactory::Create() {
  return std::make_unique<FakeArCore>();
}

}  // namespace device


text:
from tempest.api.baremetal import base
from tempest.common.utils import data_utils
from tempest import exceptions as exc
from tempest import test

class TestPortsNegative(base.BaseBaremetalTest):
    """Negative tests for ports."""

    def setUp(self):
        super(TestPortsNegative, self).setUp()

        chassis = self.create_chassis()['chassis']
        self.node = self.create_node(chassis['uuid'])['node']

    @test.attr(type='negative')
    def test_create_port_invalid_mac(self):
        node_id = self.node['uuid']
        address = 'not an uuid'

        self.assertRaises(exc.BadRequest,
                          self.create_port, node_id=node_id, address=address)

    @test.attr(type='negative')
    def test_create_port_wrong_node_id(self):
        node_id = str(data_utils.rand_uuid())

        self.assertRaises(exc.BadRequest, self.create_port, node_id=node_id)

redpajama_set_name: RedPajamaGithub


text:
<resources>
    <string name="app_name">Remote Config</string>
</resources>


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>at.irian.ankor.application (Ankor - Project 0.4-SNAPSHOT API)</title>
<meta name="date" content="2014-09-25">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Package

Next Package

Frames

No Frames

All Classes

Package at.irian.ankor.application

Interface Summary

Interface
Description

Application

By means of an Application the developer tells the Ankor framework the main infos about
 his Ankor application, like:

     name of the application (for logging)
     model lookup behaviour
     init/cleanup behaviour
     stateless/stateful

Class Summary

Class
Description

BaseApplication

Convenient base type for Ankor Applications.

CollaborationSingleRootApplication

Convenient base class for Ankor applications that support model instance sharing (i.e. collaboration).

GenericApplication

Convenient Application implementation, that is easily configurable and implements reasonable default behaviour.

SimpleClientApplication

Application implementation for Java-based Ankor clients.

SimpleSingleRootApplication

Convenient Application implementation that supports an arbitrary number of model instances that all have the same
 model root name (typically called "root").

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Package

Next Package

Frames

No Frames

All Classes

Copyright © 2014 Ankor Developers Team. All rights reserved.


text:
import Mapper from './Mapper';

export default Mapper;


text:
package org.openfact.models.jpa;

import org.jboss.logging.Logger;
import org.json.JSONObject;
import org.json.XML;
import org.openfact.JSONObjectUtils;
import org.openfact.common.converts.DocumentUtils;
import org.openfact.common.util.MultivaluedHashMap;
import org.openfact.models.*;
import org.openfact.models.jpa.entities.*;
import org.openfact.models.types.DestinyType;
import org.openfact.models.types.DocumentRequiredAction;
import org.openfact.models.types.DocumentType;
import org.openfact.models.types.SendEventStatus;
import org.openfact.models.utils.OpenfactModelUtils;
import org.openfact.pe.ubl.types.SunatDocumentType;
import org.w3c.dom.Document;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.xml.transform.TransformerException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

public class DocumentAdapter implements DocumentModel, JpaModel<DocumentEntity> {

    private static final Logger logger = Logger.getLogger(DocumentAdapter.class);

    private OrganizationModel organization;
    private DocumentEntity document;
    private FileProvider fileProvider;
    private EntityManager em;

    protected FileModel xmlFile;
    protected Document xmlDocument;
    protected JSONObject jsonObject;

    public DocumentAdapter(OrganizationModel organization, EntityManager em, DocumentEntity document, FileProvider fileProvider) {
        this.organization = organization;
        this.em = em;
        this.document = document;
        this.fileProvider = fileProvider;
    }

    public static DocumentEntity toEntity(DocumentModel model, EntityManager em) {
        if (model instanceof DocumentAdapter) {
            return ((DocumentAdapter) model).getEntity();
        }
        return em.getReference(DocumentEntity.class, model.getId());
    }

    public DocumentLineModel toDocumentLineModel(DocumentLineEntity documentLine) {
        return new DocumentLineAdapter(this, em, documentLine);
    }

    @Override
    public DocumentEntity getEntity() {
        return document;
    }

    @Override
    public String getId() {
        return document.getId();
    }

    @Override
    public String getDocumentId() {
        return document.getDocumentId();
    }

    @Override
    public String getDocumentType() {
        return document.getDocumentType();
    }

    @Override
    public Date getIssueDate() {
        return document.getIssueDate();
    }

    @Override
    public void setIssueDate(Date issueDate) {
        document.setIssueDate(issueDate);
    }

    @Override
    public Date getCreatedTimestamp() {
        return document.getCreatedTimestamp();
    }

    @Override
    public Status getStatus() {
        return document.getStatus();
    }

    @Override
    public void setStatus(Status status) {
        document.setStatus(status);
    }

    @Override
    public Integer getStatusCode() {
        return document.getStatusCode();
    }

    @Override
    public void setStatusCode(int statusCode) {
        document.setStatusCode(statusCode);
    }

    @Override
    public String getStatusMessage() {
        return document.getStatusMessage();
    }

    @Override
    public void setStatusMessage(String statusMessage) {
        document.setStatusMessage(statusMessage);
    }

    @Override
    public boolean isClosed() {
        return document.isClosed();
    }

    @Override
    public void close() {
        document.setClosed(true);
    }

    @Override
    public boolean isBajaEnProceso() {
        return document.isBajaEnProceso();
    }

    @Override
    public void setBajaEnProceso() {
        document.setBajaEnProceso(true);
        document.setBajaEnProcesoFecha(new Date());
    }

    @Override
    public boolean isSummaryVoided() {
        return document.isSummaryVoided();
    }

    @Override
    public void summaryVoided() {
        document.setSummaryVoided(true);
    }

    @Override
    public String getObservacion() {
        return document.getObservacion();
    }

    @Override
    public void setObservacion(String observacion) {
        document.setObservacion(observacion);
    }

    @Override
    public List<DocumentLineModel> getDocumentLines() {
        return document.getLines().stream()
                .map(this::toDocumentLineModel)
                .collect(Collectors.toList());
    }

    @Override
    public DocumentLineModel addDocumentLine() {
        DocumentLineEntity entity = new DocumentLineEntity();
        entity.setDocument(document);
        em.persist(entity);
        return toDocumentLineModel(entity);
    }

    @Override
    public boolean removeDocumentLine(DocumentLineModel documentLine) {
        boolean result = false;
        Iterator<DocumentLineEntity> it = document.getLines().iterator();
        while (it.hasNext()) {
            DocumentLineEntity line = it.next();
            if (line.getId().equals(documentLine.getId())) {
                it.remove();
                em.remove(line);
                result = true;
            }
        }
        return result;
    }

    @Override
    public boolean removeAllDocumentLines() {
        // Remove attribute through HQL to avoid StaleUpdateException
        Query query = em.createNamedQuery("deleteDocumentLineAttributesByDocument");
        query.setParameter("documentPkId", document.getId());
        query.executeUpdate();

        query = em.createNamedQuery("deleteDocumentLinesByDocument");
        query.setParameter("documentPkId", document.getId());
        query.executeUpdate();

        // Also remove drom document
        document.setLines(new HashSet<>());
        return true;
    }

    @Override
    public OrganizationModel getOrganization() {
        return organization;
    }

    @Override
    public String getDocumentCurrencyCode() {
        return document.getDocumentCurrencyCode();
    }

    @Override
    public void setDocumentCurrencyCode(String currencyCode) {
        document.setDocumentCurrencyCode(currencyCode);
    }

    @Override
    public String getCustomerRegistrationName() {
        return document.getCustomerRegistrationName();
    }

    @Override
    public void setCustomerRegistrationName(String value) {
        document.setCustomerRegistrationName(value);
    }

    @Override
    public String getCustomerAssignedAccountId() {
        return document.getCustomerAssignedAccountId();
    }

    @Override
    public void setCustomerAssignedAccountId(String value) {
        document.setCustomerAssignedAccountId(value);
    }

    @Override
    public String getCustomerElectronicMail() {
        return document.getCustomerElectronicMail();
    }

    @Override
    public void setCustomerElectronicMail(String value) {
        document.setCustomerElectronicMail(value);
    }

    /*
     * Document*/
    @Override
    public FileModel getXmlAsFile() {
        if (xmlFile == null && document.getXmlFileId() != null) {
            xmlFile = fileProvider.getFileById(organization, document.getXmlFileId());
        }
        return xmlFile;
    }

    @Override
    public void attachXmlFile(FileModel file) {
        xmlFile = file;
        document.setXmlFileId(xmlFile.getId());
    }

    @Override
    public Document getXmlAsDocument() {
        if (xmlDocument == null) {
            FileModel file = getXmlAsFile();
            if (file != null) {
                try {
                    xmlDocument = DocumentUtils.byteToDocument(file.getFile());
                } catch (Exception e) {
                    logger.error("Error parsing xml file to Document", e);
                    throw new ModelRuntimeException("Error parsing xml file to Document", e);
                }
            }
        }
        return xmlDocument;
    }

    @Override
    public JSONObject getXmlAsJSONObject() {
        if (jsonObject == null) {
            try {
                Document document = getXmlAsDocument();
                if (document != null) {
                    String documentString = DocumentUtils.getDocumentToString(document);
                    jsonObject = JSONObjectUtils.renameKey(XML.toJSONObject(documentString), ".*:", "");
                    DocumentType documentType = DocumentType.getFromString(this.document.getDocumentType());
                    if (documentType != null) {
                        switch (documentType) {
                            case INVOICE:
                                jsonObject = JSONObjectUtils.getJSONObject(jsonObject, DocumentType.INVOICE.getXmlWrapper());
                                break;
                            case CREDIT_NOTE:
                                jsonObject = JSONObjectUtils.getJSONObject(jsonObject, DocumentType.CREDIT_NOTE.getXmlWrapper());
                                break;
                            case DEBIT_NOTE:
                                jsonObject = JSONObjectUtils.getJSONObject(jsonObject, DocumentType.DEBIT_NOTE.getXmlWrapper());
                                break;
                            case DESPATCH_ADVICE:
                                jsonObject = JSONObjectUtils.getJSONObject(jsonObject, DocumentType.DESPATCH_ADVICE.getXmlWrapper());
                                break;
                        }
                    } else {
                        SunatDocumentType sunatDocumentType = SunatDocumentType.getFromString(this.document.getDocumentType());
                        if (sunatDocumentType != null) {
                            switch (sunatDocumentType) {
                                case RETENTION:
                                    jsonObject = JSONObjectUtils.getJSONObject(jsonObject, SunatDocumentType.RETENTION.getXmlWrapper());
                                    break;
                                case PERCEPTION:
                                    jsonObject = JSONObjectUtils.getJSONObject(jsonObject, SunatDocumentType.PERCEPTION.getXmlWrapper());
                                    break;
                                case SUMMARY_DOCUMENTS:
                                    jsonObject = JSONObjectUtils.getJSONObject(jsonObject, SunatDocumentType.SUMMARY_DOCUMENTS.getXmlWrapper());
                                    break;
                                case VOIDED_DOCUMENTS:
                                    jsonObject = JSONObjectUtils.getJSONObject(jsonObject, SunatDocumentType.VOIDED_DOCUMENTS.getXmlWrapper());
                                    break;
                                case SUMMARY_VOIDED_DOCUMENTS:
                                    jsonObject = JSONObjectUtils.getJSONObject(jsonObject, SunatDocumentType.SUMMARY_VOIDED_DOCUMENTS.getXmlWrapper());
                                    break;
                            }

                        } else {

                            String jsonName = Arrays.stream(this.document.getDocumentType().toLowerCase().split("_"))
                                    .map(c -> c.substring(0, 1).toUpperCase() + c.substring(1))
                                    .reduce("", String::concat);
                            JSONObject subJsonObject = JSONObjectUtils.getJSONObject(jsonObject, jsonName);
                            if (subJsonObject != null) {
                                jsonObject = subJsonObject;
                            }
                        }
                    }
                    return jsonObject;
                }
            } catch (TransformerException e) {
                logger.error("Error parsing xml file to JSON", e);
                throw new ModelRuntimeException("Error parsing xml file to JSON", e);
            }
        }
        return jsonObject;
    }

    @Override
    public FileModel getCdrFile() {
        if (document.getCdrFileId() != null) {
            return fileProvider.getFileById(organization, document.getCdrFileId());
        }
        return null;
    }

    @Override
    public void setCrdFile(FileModel cdrFile) {
        document.setCdrFileId(cdrFile.getId());
    }

    @Override
    public String getXmlDigestValue() {
        return document.getXmlDigestValue();
    }

    @Override
    public void setXmlDigestValue(String digestValue) {
        document.setXmlDigestValue(digestValue);
    }

    /**
     * Attributes
     */
    @Override
    public void setSingleAttribute(String name, String value) {
        String firstExistingAttrId = null;
        List<DocumentAttributeEntity> toRemove = new ArrayList<>();
        for (DocumentAttributeEntity attr : document.getAttributes()) {
            if (attr.getName().equals(name)) {
                if (firstExistingAttrId == null) {
                    attr.setValue(value);
                    firstExistingAttrId = attr.getId();
                } else {
                    toRemove.add(attr);
                }
            }
        }

        if (firstExistingAttrId != null) {
            // Remove attributes through HQL to avoid StaleUpdateException
            Query query = em.createNamedQuery("deleteDocumentAttributesByNameAndDocumentPkIdOtherThan");
            query.setParameter("name", name);
            query.setParameter("documentPkId", document.getId());
            query.setParameter("attrId", firstExistingAttrId);
            query.executeUpdate();

            // Remove attribute from local entity
            document.getAttributes().removeAll(toRemove);
        } else {

            persistAttributeValue(name, value);
        }
    }

    @Override
    public void setAttribute(String name, List<String> values) {
        // Remove all existing
        removeAttribute(name);

        // Put all new
        for (String value : values) {
            persistAttributeValue(name, value);
        }
    }

    private void persistAttributeValue(String name, String value) {
        DocumentAttributeEntity attr = new DocumentAttributeEntity();
        attr.setId(OpenfactModelUtils.generateId());
        attr.setName(name);
        attr.setValue(value);
        attr.setDocument(document);
        em.persist(attr);
        document.getAttributes().add(attr);
    }

    @Override
    public void removeAttribute(String name) {
        // Remove attribute through HQL to avoid StaleUpdateException
        Query query = em.createNamedQuery("deleteDocumentAttributesByNameAndDocumentPkId");
        query.setParameter("name", name);
        query.setParameter("documentPkId", document.getId());
        query.executeUpdate();

        // Also remove attributes from local user entity
        List<DocumentAttributeEntity> toRemove = new ArrayList<>();
        for (DocumentAttributeEntity attr : document.getAttributes()) {
            if (attr.getName().equals(name)) {
                toRemove.add(attr);
            }
        }
        document.getAttributes().removeAll(toRemove);
    }

    @Override
    public String getFirstAttribute(String name) {
        for (DocumentAttributeEntity attr : document.getAttributes()) {
            if (attr.getName().equals(name)) {
                return attr.getValue();
            }
        }
        return null;
    }

    @Override
    public List<String> getAttribute(String name) {
        List<String> result = new ArrayList<>();
        for (DocumentAttributeEntity attr : document.getAttributes()) {
            if (attr.getName().equals(name)) {
                result.add(attr.getValue());
            }
        }
        return result;
    }

    @Override
    public Map<String, List<String>> getAttributes() {
        MultivaluedHashMap<String, String> result = new MultivaluedHashMap<>();
        for (DocumentAttributeEntity attr : document.getAttributes()) {
            result.add(attr.getName(), attr.getValue());
        }
        return result;
    }

    /**
     * Required actions
     */
    @Override
    public Set<String> getRequiredActions() {
        Set<String> result = new HashSet<>();
        for (DocumentRequiredActionEntity attr : document.getRequiredActions()) {
            result.add(attr.getAction());
        }
        return result;
    }

    @Override
    public void addRequiredAction(DocumentRequiredAction action) {
        String actionName = action.name();
        addRequiredAction(actionName);
    }

    @Override
    public void addRequiredAction(String actionName) {
        for (DocumentRequiredActionEntity attr : document.getRequiredActions()) {
            if (attr.getAction().equals(actionName)) {
                return;
            }
        }
        DocumentRequiredActionEntity attr = new DocumentRequiredActionEntity();
        attr.setAction(actionName);
        attr.setDocument(document);
        em.persist(attr);
        document.getRequiredActions().add(attr);
    }

    @Override
    public void removeRequiredAction(DocumentRequiredAction action) {
        String actionName = action.name();
        removeRequiredAction(actionName);
    }

    @Override
    public int getCustomerSendEventFailures() {
        return document.getCustomerSendEventFailures();
    }

    @Override
    public void incrementCustomerSendEventFailures() {
        document.setCustomerSendEventFailures(document.getCustomerSendEventFailures() + 1);
    }

    @Override
    public int getThirdPartySendEventFailures() {
        return document.getThirdPartySendEventFailures();
    }

    @Override
    public void incrementThirdPartySendEventFailures() {
        document.setThirdPartySendEventFailures(document.getThirdPartySendEventFailures() + 1);
    }

    @Override
    public void removeRequiredAction(String actionName) {
        Iterator<DocumentRequiredActionEntity> it = document.getRequiredActions().iterator();
        while (it.hasNext()) {
            DocumentRequiredActionEntity attr = it.next();
            if (attr.getAction().equals(actionName)) {
                it.remove();
                em.remove(attr);
            }
        }
    }

    /**
     * Send events
     */
    @Override
    public SendEventModel addSendEvent(DestinyType destinyType) {
        SendEventEntity entity = new SendEventEntity();
        entity.setCreatedTimestamp(LocalDateTime.now());
        entity.setStatus(SendEventStatus.ON_PROCESS);
        entity.setDestiny(destinyType);
        entity.setDocument(document);
        em.persist(entity);

        return new SendEventAdapter(em, organization, entity);
    }

    @Override
    public SendEventModel getSendEventById(String id) {
        SendEventEntity entity = em.find(SendEventEntity.class, id);
        if (entity != null) {
            return new SendEventAdapter(em, organization, entity);
        }
        return null;
    }

    @Override
    public boolean removeSendEvent(SendEventModel sendEvent) {
        SendEventEntity entity = em.find(SendEventEntity.class, sendEvent.getId());
        if (entity == null)
            return false;

        em.remove(entity);
        em.flush();
        return true;
    }

    @Override
    public List<SendEventModel> getSendEvents() {
        return getSendEvents(-1, -1);
    }

    @Override
    public List<SendEventModel> getSendEvents(Integer firstResult, Integer maxResults) {
        TypedQuery<SendEventEntity> query = em.createNamedQuery("getAllSendEventsByDocumentPkId", SendEventEntity.class);
        query.setParameter("documentPkId", document.getId());
        if (firstResult != -1) {
            query.setFirstResult(firstResult);
        }
        if (maxResults != -1) {
            query.setMaxResults(maxResults);
        }
        List<SendEventEntity> results = query.getResultList();
        return results.stream().map(f -> new SendEventAdapter(em, organization, f)).collect(Collectors.toList());
    }

    @Override
    public List<SendEventModel> searchForSendEvent(Map<String, String> params) {
        return searchForSendEvent(params, -1, -1);
    }

    @Override
    public List<SendEventModel> searchForSendEvent(Map<String, String> attributes, int firstResult, int maxResults) {
        StringBuilder builder = new StringBuilder("select u from SendEventEntity u where u.document.id = :documentId");
        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            String attribute = null;
            String parameterName = null;
            String operator = null;
            if (entry.getKey().equals(DocumentModel.SEND_EVENT_DESTINY)) {
                attribute = "u." + JpaDocumentProvider.SEND_EVENT_DESTINY;
                parameterName = JpaDocumentProvider.SEND_EVENT_DESTINY;
                operator = " = :";
            } else if (entry.getKey().equals(DocumentModel.SEND_EVENT_STATUS)) {
                attribute = "u." + JpaDocumentProvider.SEND_EVENT_STATUS;
                parameterName = JpaDocumentProvider.SEND_EVENT_STATUS;
                operator = " = :";
            }
            if (attribute == null) continue;
            builder.append(" and ");
            builder.append(attribute).append(operator).append(parameterName);
        }
        builder.append(" order by u.createdTimestamp");
        String q = builder.toString();
        TypedQuery<SendEventEntity> query = em.createQuery(q, SendEventEntity.class);
        query.setParameter("documentId", document.getId());
        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            String parameterName = null;
            Object parameterValue = null;
            if (entry.getKey().equals(DocumentModel.SEND_EVENT_DESTINY)) {
                parameterName = JpaDocumentProvider.SEND_EVENT_DESTINY;
                parameterValue = DestinyType.valueOf(entry.getValue().toUpperCase());
            } else if (entry.getKey().equals(DocumentModel.SEND_EVENT_STATUS)) {
                parameterName = JpaDocumentProvider.SEND_EVENT_STATUS;
                parameterValue = SendEventStatus.valueOf(entry.getValue().toUpperCase());
            }
            if (parameterName == null) continue;
            query.setParameter(parameterName, parameterValue);
        }
        if (firstResult != -1) {
            query.setFirstResult(firstResult);
        }
        if (maxResults != -1) {
            query.setMaxResults(maxResults);
        }
        List<SendEventEntity> results = query.getResultList();
        return results.stream().map(f -> new SendEventAdapter(em, organization, f)).collect(Collectors.toList());
    }

    /**
     * Attatched documents
     */
    @Override
    public List<DocumentModel> getAttachedDocumentsAsOrigin() {
        TypedQuery<DocumentEntity> query = em.createNamedQuery("getAttachedDocumentsDestinyByOrigin", DocumentEntity.class);
        query.setParameter("documentOriginId", document.getId());
        return query.getResultList().stream().map(f -> new DocumentAdapter(organization, em, f, fileProvider)).collect(Collectors.toList());
    }

    @Override
    public List<DocumentModel> getAttachedDocumentsAsDestiny() {
        TypedQuery<DocumentEntity> query = em.createNamedQuery("getAttachedDocumentsOriginByDestiny", DocumentEntity.class);
        query.setParameter("documentDestinyId", document.getId());
        return query.getResultList().stream().map(f -> new DocumentAdapter(organization, em, f, fileProvider)).collect(Collectors.toList());
    }

    @Override
    public void addAttachedDocument(DocumentModel document) {
        AttachedDocumentEntity entity = new AttachedDocumentEntity();
        entity.setDocumentOrigin(this.document);
        entity.setDocumentDestiny(DocumentAdapter.toEntity(document, em));
        em.persist(entity);
        this.document.getAttachedDocumentsAsOrigin().add(entity);
    }

    @Override
    public boolean removeAttachedDocument(DocumentModel document) {
        boolean result = false;
        Iterator<AttachedDocumentEntity> it = this.document.getAttachedDocumentsAsOrigin().iterator();
        while (it.hasNext()) {
            AttachedDocumentEntity attachedUBLDocument = it.next();
            if (attachedUBLDocument.getDocumentDestiny().getId().equals(document.getId())) {
                it.remove();
                em.remove(attachedUBLDocument);
                result = true;
            }
        }
        return result;
    }

    @Override
    public boolean removeAllAttachedDocuments() {
        // Remove attribute through HQL to avoid StaleUpdateException
        Query query = em.createNamedQuery("deleteAttachedDocumentsByOriginDocument");
        query.setParameter("documentOriginId", document.getId());
        query.executeUpdate();

        // Also remove drom document
        document.setLines(new HashSet<>());
        return true;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || !(o instanceof DocumentModel)) return false;

        DocumentModel that = (DocumentModel) o;
        return that.getId().equals(getId());
    }

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

}


text:
package com.vmware.vim25;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for VirtualMachineDefaultPowerOpInfo complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="VirtualMachineDefaultPowerOpInfo">
 *   <complexContent>
 *     <extension base="{urn:vim25}DynamicData">
 *       <sequence>
 *         <element name="powerOffType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="suspendType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="resetType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="defaultPowerOffType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="defaultSuspendType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="defaultResetType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="standbyAction" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       </sequence>
 *     </extension>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "VirtualMachineDefaultPowerOpInfo", propOrder = {
    "powerOffType",
    "suspendType",
    "resetType",
    "defaultPowerOffType",
    "defaultSuspendType",
    "defaultResetType",
    "standbyAction"
})
public class VirtualMachineDefaultPowerOpInfo
    extends DynamicData
{

    protected String powerOffType;
    protected String suspendType;
    protected String resetType;
    protected String defaultPowerOffType;
    protected String defaultSuspendType;
    protected String defaultResetType;
    protected String standbyAction;

    /**
     * Gets the value of the powerOffType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getPowerOffType() {
        return powerOffType;
    }

    /**
     * Sets the value of the powerOffType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setPowerOffType(String value) {
        this.powerOffType = value;
    }

    /**
     * Gets the value of the suspendType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSuspendType() {
        return suspendType;
    }

    /**
     * Sets the value of the suspendType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSuspendType(String value) {
        this.suspendType = value;
    }

    /**
     * Gets the value of the resetType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getResetType() {
        return resetType;
    }

    /**
     * Sets the value of the resetType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setResetType(String value) {
        this.resetType = value;
    }

    /**
     * Gets the value of the defaultPowerOffType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDefaultPowerOffType() {
        return defaultPowerOffType;
    }

    /**
     * Sets the value of the defaultPowerOffType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDefaultPowerOffType(String value) {
        this.defaultPowerOffType = value;
    }

    /**
     * Gets the value of the defaultSuspendType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDefaultSuspendType() {
        return defaultSuspendType;
    }

    /**
     * Sets the value of the defaultSuspendType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDefaultSuspendType(String value) {
        this.defaultSuspendType = value;
    }

    /**
     * Gets the value of the defaultResetType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDefaultResetType() {
        return defaultResetType;
    }

    /**
     * Sets the value of the defaultResetType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDefaultResetType(String value) {
        this.defaultResetType = value;
    }

    /**
     * Gets the value of the standbyAction property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getStandbyAction() {
        return standbyAction;
    }

    /**
     * Sets the value of the standbyAction property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setStandbyAction(String value) {
        this.standbyAction = value;
    }

}


text:
from sanic import Blueprint, response

bp_template = Blueprint("template")

@bp_template.route("/template/<name>", methods=["GET"])
async def page_template(request, name):
    if(request.app.debug is False):
        return response.redirect("/", status=301)

    try:
        template_env = request.app.config.template_env

        t = template_env.get_template("{}.html.j2".format(name))

        rendered_template = await t.render_async()

        return response.html(rendered_template)

    except(j2.exceptions.TemplateNotFound):
        return response.text("The template of '{}' was not found because you probably spelled it wrong.".format(name))


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

package com.google.cloud.compute.v1;

/**
 *
 *
 *

 *

 *
 * Protobuf type {@code google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest}
 */
public final class GlobalOrganizationSetPolicyRequest extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest)
    GlobalOrganizationSetPolicyRequestOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use GlobalOrganizationSetPolicyRequest.newBuilder() to construct.
  private GlobalOrganizationSetPolicyRequest(
      com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private GlobalOrganizationSetPolicyRequest() {
    bindings_ = java.util.Collections.emptyList();
    etag_ = "";
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new GlobalOrganizationSetPolicyRequest();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.compute.v1.Compute
        .internal_static_google_cloud_compute_v1_GlobalOrganizationSetPolicyRequest_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.compute.v1.Compute
        .internal_static_google_cloud_compute_v1_GlobalOrganizationSetPolicyRequest_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.class,
            com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.Builder.class);
  }

  private int bitField0_;
  public static final int BINDINGS_FIELD_NUMBER = 403251854;
  private java.util.List<com.google.cloud.compute.v1.Binding> bindings_;
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
   *

   *
   * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
   */
  @java.lang.Override
  public java.util.List<com.google.cloud.compute.v1.Binding> getBindingsList() {
    return bindings_;
  }
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
   *

   *
   * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
   */
  @java.lang.Override
  public java.util.List<? extends com.google.cloud.compute.v1.BindingOrBuilder>
      getBindingsOrBuilderList() {
    return bindings_;
  }
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
   *

   *
   * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
   */
  @java.lang.Override
  public int getBindingsCount() {
    return bindings_.size();
  }
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
   *

   *
   * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
   */
  @java.lang.Override
  public com.google.cloud.compute.v1.Binding getBindings(int index) {
    return bindings_.get(index);
  }
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
   *

   *
   * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
   */
  @java.lang.Override
  public com.google.cloud.compute.v1.BindingOrBuilder getBindingsOrBuilder(int index) {
    return bindings_.get(index);
  }

  public static final int ETAG_FIELD_NUMBER = 3123477;
  private volatile java.lang.Object etag_;
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
   *

   *
   * optional string etag = 3123477;
   *
   * @return Whether the etag field is set.
   */
  @java.lang.Override
  public boolean hasEtag() {
    return ((bitField0_ & 0x00000001) != 0);
  }
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
   *

   *
   * optional string etag = 3123477;
   *
   * @return The etag.
   */
  @java.lang.Override
  public java.lang.String getEtag() {
    java.lang.Object ref = etag_;
    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();
      etag_ = s;
      return s;
    }
  }
  /**
   *
   *
   *

   * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
   *

   *
   * optional string etag = 3123477;
   *
   * @return The bytes for etag.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getEtagBytes() {
    java.lang.Object ref = etag_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      etag_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int POLICY_FIELD_NUMBER = 91071794;
  private com.google.cloud.compute.v1.Policy policy_;
  /**
   *
   *
   *

   * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
   *

   *
   * optional .google.cloud.compute.v1.Policy policy = 91071794;
   *
   * @return Whether the policy field is set.
   */
  @java.lang.Override
  public boolean hasPolicy() {
    return ((bitField0_ & 0x00000002) != 0);
  }
  /**
   *
   *
   *

   * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
   *

   *
   * optional .google.cloud.compute.v1.Policy policy = 91071794;
   *
   * @return The policy.
   */
  @java.lang.Override
  public com.google.cloud.compute.v1.Policy getPolicy() {
    return policy_ == null ? com.google.cloud.compute.v1.Policy.getDefaultInstance() : policy_;
  }
  /**
   *
   *
   *

   * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
   *

   *
   * optional .google.cloud.compute.v1.Policy policy = 91071794;
   */
  @java.lang.Override
  public com.google.cloud.compute.v1.PolicyOrBuilder getPolicyOrBuilder() {
    return policy_ == null ? com.google.cloud.compute.v1.Policy.getDefaultInstance() : policy_;
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    if (((bitField0_ & 0x00000001) != 0)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 3123477, etag_);
    }
    if (((bitField0_ & 0x00000002) != 0)) {
      output.writeMessage(91071794, getPolicy());
    }
    for (int i = 0; i < bindings_.size(); i++) {
      output.writeMessage(403251854, bindings_.get(i));
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) != 0)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3123477, etag_);
    }
    if (((bitField0_ & 0x00000002) != 0)) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(91071794, getPolicy());
    }
    for (int i = 0; i < bindings_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(403251854, bindings_.get(i));
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest)) {
      return super.equals(obj);
    }
    com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest other =
        (com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest) obj;

    if (!getBindingsList().equals(other.getBindingsList())) return false;
    if (hasEtag() != other.hasEtag()) return false;
    if (hasEtag()) {
      if (!getEtag().equals(other.getEtag())) return false;
    }
    if (hasPolicy() != other.hasPolicy()) return false;
    if (hasPolicy()) {
      if (!getPolicy().equals(other.getPolicy())) return false;
    }
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getBindingsCount() > 0) {
      hash = (37 * hash) + BINDINGS_FIELD_NUMBER;
      hash = (53 * hash) + getBindingsList().hashCode();
    }
    if (hasEtag()) {
      hash = (37 * hash) + ETAG_FIELD_NUMBER;
      hash = (53 * hash) + getEtag().hashCode();
    }
    if (hasPolicy()) {
      hash = (37 * hash) + POLICY_FIELD_NUMBER;
      hash = (53 * hash) + getPolicy().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest 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.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest 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.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest 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.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(
      com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  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.cloud.compute.v1.GlobalOrganizationSetPolicyRequest}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest)
      com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequestOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.compute.v1.Compute
          .internal_static_google_cloud_compute_v1_GlobalOrganizationSetPolicyRequest_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.compute.v1.Compute
          .internal_static_google_cloud_compute_v1_GlobalOrganizationSetPolicyRequest_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.class,
              com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.Builder.class);
    }

    // Construct using com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }

    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
        getBindingsFieldBuilder();
        getPolicyFieldBuilder();
      }
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      if (bindingsBuilder_ == null) {
        bindings_ = java.util.Collections.emptyList();
      } else {
        bindings_ = null;
        bindingsBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000001);
      etag_ = "";
      bitField0_ = (bitField0_ & ~0x00000002);
      if (policyBuilder_ == null) {
        policy_ = null;
      } else {
        policyBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000004);
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.compute.v1.Compute
          .internal_static_google_cloud_compute_v1_GlobalOrganizationSetPolicyRequest_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest
        getDefaultInstanceForType() {
      return com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest build() {
      com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest buildPartial() {
      com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest result =
          new com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      if (bindingsBuilder_ == null) {
        if (((bitField0_ & 0x00000001) != 0)) {
          bindings_ = java.util.Collections.unmodifiableList(bindings_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.bindings_ = bindings_;
      } else {
        result.bindings_ = bindingsBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000002) != 0)) {
        to_bitField0_ |= 0x00000001;
      }
      result.etag_ = etag_;
      if (((from_bitField0_ & 0x00000004) != 0)) {
        if (policyBuilder_ == null) {
          result.policy_ = policy_;
        } else {
          result.policy_ = policyBuilder_.build();
        }
        to_bitField0_ |= 0x00000002;
      }
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest) {
        return mergeFrom((com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest other) {
      if (other
          == com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest.getDefaultInstance())
        return this;
      if (bindingsBuilder_ == null) {
        if (!other.bindings_.isEmpty()) {
          if (bindings_.isEmpty()) {
            bindings_ = other.bindings_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureBindingsIsMutable();
            bindings_.addAll(other.bindings_);
          }
          onChanged();
        }
      } else {
        if (!other.bindings_.isEmpty()) {
          if (bindingsBuilder_.isEmpty()) {
            bindingsBuilder_.dispose();
            bindingsBuilder_ = null;
            bindings_ = other.bindings_;
            bitField0_ = (bitField0_ & ~0x00000001);
            bindingsBuilder_ =
                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
                    ? getBindingsFieldBuilder()
                    : null;
          } else {
            bindingsBuilder_.addAllMessages(other.bindings_);
          }
        }
      }
      if (other.hasEtag()) {
        bitField0_ |= 0x00000002;
        etag_ = other.etag_;
        onChanged();
      }
      if (other.hasPolicy()) {
        mergePolicy(other.getPolicy());
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 24987818:
              {
                etag_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000002;
                break;
              } // case 24987818
            case 728574354:
              {
                input.readMessage(getPolicyFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000004;
                break;
              } // case 728574354
            case -1068952462:
              {
                com.google.cloud.compute.v1.Binding m =
                    input.readMessage(
                        com.google.cloud.compute.v1.Binding.parser(), extensionRegistry);
                if (bindingsBuilder_ == null) {
                  ensureBindingsIsMutable();
                  bindings_.add(m);
                } else {
                  bindingsBuilder_.addMessage(m);
                }
                break;
              } // case -1068952462
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.util.List<com.google.cloud.compute.v1.Binding> bindings_ =
        java.util.Collections.emptyList();

    private void ensureBindingsIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        bindings_ = new java.util.ArrayList<com.google.cloud.compute.v1.Binding>(bindings_);
        bitField0_ |= 0x00000001;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.compute.v1.Binding,
            com.google.cloud.compute.v1.Binding.Builder,
            com.google.cloud.compute.v1.BindingOrBuilder>
        bindingsBuilder_;

    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public java.util.List<com.google.cloud.compute.v1.Binding> getBindingsList() {
      if (bindingsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(bindings_);
      } else {
        return bindingsBuilder_.getMessageList();
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public int getBindingsCount() {
      if (bindingsBuilder_ == null) {
        return bindings_.size();
      } else {
        return bindingsBuilder_.getCount();
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public com.google.cloud.compute.v1.Binding getBindings(int index) {
      if (bindingsBuilder_ == null) {
        return bindings_.get(index);
      } else {
        return bindingsBuilder_.getMessage(index);
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder setBindings(int index, com.google.cloud.compute.v1.Binding value) {
      if (bindingsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureBindingsIsMutable();
        bindings_.set(index, value);
        onChanged();
      } else {
        bindingsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder setBindings(
        int index, com.google.cloud.compute.v1.Binding.Builder builderForValue) {
      if (bindingsBuilder_ == null) {
        ensureBindingsIsMutable();
        bindings_.set(index, builderForValue.build());
        onChanged();
      } else {
        bindingsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder addBindings(com.google.cloud.compute.v1.Binding value) {
      if (bindingsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureBindingsIsMutable();
        bindings_.add(value);
        onChanged();
      } else {
        bindingsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder addBindings(int index, com.google.cloud.compute.v1.Binding value) {
      if (bindingsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureBindingsIsMutable();
        bindings_.add(index, value);
        onChanged();
      } else {
        bindingsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder addBindings(com.google.cloud.compute.v1.Binding.Builder builderForValue) {
      if (bindingsBuilder_ == null) {
        ensureBindingsIsMutable();
        bindings_.add(builderForValue.build());
        onChanged();
      } else {
        bindingsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder addBindings(
        int index, com.google.cloud.compute.v1.Binding.Builder builderForValue) {
      if (bindingsBuilder_ == null) {
        ensureBindingsIsMutable();
        bindings_.add(index, builderForValue.build());
        onChanged();
      } else {
        bindingsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder addAllBindings(
        java.lang.Iterable<? extends com.google.cloud.compute.v1.Binding> values) {
      if (bindingsBuilder_ == null) {
        ensureBindingsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, bindings_);
        onChanged();
      } else {
        bindingsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder clearBindings() {
      if (bindingsBuilder_ == null) {
        bindings_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
      } else {
        bindingsBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public Builder removeBindings(int index) {
      if (bindingsBuilder_ == null) {
        ensureBindingsIsMutable();
        bindings_.remove(index);
        onChanged();
      } else {
        bindingsBuilder_.remove(index);
      }
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public com.google.cloud.compute.v1.Binding.Builder getBindingsBuilder(int index) {
      return getBindingsFieldBuilder().getBuilder(index);
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public com.google.cloud.compute.v1.BindingOrBuilder getBindingsOrBuilder(int index) {
      if (bindingsBuilder_ == null) {
        return bindings_.get(index);
      } else {
        return bindingsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public java.util.List<? extends com.google.cloud.compute.v1.BindingOrBuilder>
        getBindingsOrBuilderList() {
      if (bindingsBuilder_ != null) {
        return bindingsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(bindings_);
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public com.google.cloud.compute.v1.Binding.Builder addBindingsBuilder() {
      return getBindingsFieldBuilder()
          .addBuilder(com.google.cloud.compute.v1.Binding.getDefaultInstance());
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public com.google.cloud.compute.v1.Binding.Builder addBindingsBuilder(int index) {
      return getBindingsFieldBuilder()
          .addBuilder(index, com.google.cloud.compute.v1.Binding.getDefaultInstance());
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings.
     *

     *
     * repeated .google.cloud.compute.v1.Binding bindings = 403251854;
     */
    public java.util.List<com.google.cloud.compute.v1.Binding.Builder> getBindingsBuilderList() {
      return getBindingsFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.compute.v1.Binding,
            com.google.cloud.compute.v1.Binding.Builder,
            com.google.cloud.compute.v1.BindingOrBuilder>
        getBindingsFieldBuilder() {
      if (bindingsBuilder_ == null) {
        bindingsBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilderV3<
                com.google.cloud.compute.v1.Binding,
                com.google.cloud.compute.v1.Binding.Builder,
                com.google.cloud.compute.v1.BindingOrBuilder>(
                bindings_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
        bindings_ = null;
      }
      return bindingsBuilder_;
    }

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

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
     *

     *
     * optional string etag = 3123477;
     *
     * @return Whether the etag field is set.
     */
    public boolean hasEtag() {
      return ((bitField0_ & 0x00000002) != 0);
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
     *

     *
     * optional string etag = 3123477;
     *
     * @return The etag.
     */
    public java.lang.String getEtag() {
      java.lang.Object ref = etag_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        etag_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
     *

     *
     * optional string etag = 3123477;
     *
     * @return The bytes for etag.
     */
    public com.google.protobuf.ByteString getEtagBytes() {
      java.lang.Object ref = etag_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        etag_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
     *

     *
     * optional string etag = 3123477;
     *
     * @param value The etag to set.
     * @return This builder for chaining.
     */
    public Builder setEtag(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      bitField0_ |= 0x00000002;
      etag_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
     *

     *
     * optional string etag = 3123477;
     *
     * @return This builder for chaining.
     */
    public Builder clearEtag() {
      bitField0_ = (bitField0_ & ~0x00000002);
      etag_ = getDefaultInstance().getEtag();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag.
     *

     *
     * optional string etag = 3123477;
     *
     * @param value The bytes for etag to set.
     * @return This builder for chaining.
     */
    public Builder setEtagBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      bitField0_ |= 0x00000002;
      etag_ = value;
      onChanged();
      return this;
    }

    private com.google.cloud.compute.v1.Policy policy_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.compute.v1.Policy,
            com.google.cloud.compute.v1.Policy.Builder,
            com.google.cloud.compute.v1.PolicyOrBuilder>
        policyBuilder_;
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     *
     * @return Whether the policy field is set.
     */
    public boolean hasPolicy() {
      return ((bitField0_ & 0x00000004) != 0);
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     *
     * @return The policy.
     */
    public com.google.cloud.compute.v1.Policy getPolicy() {
      if (policyBuilder_ == null) {
        return policy_ == null ? com.google.cloud.compute.v1.Policy.getDefaultInstance() : policy_;
      } else {
        return policyBuilder_.getMessage();
      }
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    public Builder setPolicy(com.google.cloud.compute.v1.Policy value) {
      if (policyBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        policy_ = value;
        onChanged();
      } else {
        policyBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000004;
      return this;
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    public Builder setPolicy(com.google.cloud.compute.v1.Policy.Builder builderForValue) {
      if (policyBuilder_ == null) {
        policy_ = builderForValue.build();
        onChanged();
      } else {
        policyBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000004;
      return this;
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    public Builder mergePolicy(com.google.cloud.compute.v1.Policy value) {
      if (policyBuilder_ == null) {
        if (((bitField0_ & 0x00000004) != 0)
            && policy_ != null
            && policy_ != com.google.cloud.compute.v1.Policy.getDefaultInstance()) {
          policy_ =
              com.google.cloud.compute.v1.Policy.newBuilder(policy_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          policy_ = value;
        }
        onChanged();
      } else {
        policyBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000004;
      return this;
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    public Builder clearPolicy() {
      if (policyBuilder_ == null) {
        policy_ = null;
        onChanged();
      } else {
        policyBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000004);
      return this;
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    public com.google.cloud.compute.v1.Policy.Builder getPolicyBuilder() {
      bitField0_ |= 0x00000004;
      onChanged();
      return getPolicyFieldBuilder().getBuilder();
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    public com.google.cloud.compute.v1.PolicyOrBuilder getPolicyOrBuilder() {
      if (policyBuilder_ != null) {
        return policyBuilder_.getMessageOrBuilder();
      } else {
        return policy_ == null ? com.google.cloud.compute.v1.Policy.getDefaultInstance() : policy_;
      }
    }
    /**
     *
     *
     *

     * REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them.
     *

     *
     * optional .google.cloud.compute.v1.Policy policy = 91071794;
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.compute.v1.Policy,
            com.google.cloud.compute.v1.Policy.Builder,
            com.google.cloud.compute.v1.PolicyOrBuilder>
        getPolicyFieldBuilder() {
      if (policyBuilder_ == null) {
        policyBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.cloud.compute.v1.Policy,
                com.google.cloud.compute.v1.Policy.Builder,
                com.google.cloud.compute.v1.PolicyOrBuilder>(
                getPolicy(), getParentForChildren(), isClean());
        policy_ = null;
      }
      return policyBuilder_;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest)
  private static final com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest
      DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest();
  }

  public static com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest
      getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<GlobalOrganizationSetPolicyRequest> PARSER =
      new com.google.protobuf.AbstractParser<GlobalOrganizationSetPolicyRequest>() {
        @java.lang.Override
        public GlobalOrganizationSetPolicyRequest parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

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

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

  @java.lang.Override
  public com.google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest
      getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}